General FAQGeneral FAQ
Technical FAQ
Site managementSite management

CGI Scripting FAQ

  1. How do I install a counter in my page?
  2. How do I setup Java Chat and Email form (feedback form)
  3. My CGI script doesn't work? (Binary, ASCII & Permissons)
  4. What are forms and CGI's?
  5. Does Internet Weg Gateway offer any stock CGI scripts?
  6. How do I implement custom scripts?
  7. Where do I put my CGI scripts?
  8. How to use forms with our mailer?
  9. How to use the stock search engine?
  10. How to use the stock guestbook?
  11. How to use the random image generator?
  12. What are environment variables?

How do I install a counter in my page?

If you are using Microsoft FrontPage 98, click here to add a FrontPage Hit Counter to your Web Page.

We've installed the Muquit graphical counter for our servers.

Add this tag to use it on your site:

<IMG SRC="http://www.yourdomain.com/cgi-bin/Count.cgi?df=yourdomainXX.dat" align=absmiddle>

Where yourdomainXX.dat is your domain name with 2 digits.

For example, if your domain is somedom.com, you could use df=somedom01.dat. If you need more counters (for other pages), use a different number suffix (like somedom02.dat).

For all the details and features of this great little counter go to the Counter Documentation Pages.

To have the counter tag automatically generated, visit UserServices. There you can choose different borders and digit display styles.



Top How do I setup Java Chat, Email form (feedback form)
The following configurations can be done by a technician for a cost of US$50 each (they are free if you configure them yourself):

  • Java Chat (UNIX servers only)
    Instructions:
    • Telnet to your account
    • cd HTML (For help with UNIX commands click here)
    • mkdir chat
    • cd chat
    • cp -rv /w/chattemplate/* ~/HTML/chat
    • Load your web browser, and read the installation instructions at http:///www.your-domain.com/chat/install.html

  • Email/Order form (UNIX servers only)


    Top My CGI script doesn't work? (Binary, ASCII & Permissons)

    Most problems with CGI scripts (assuming they are written correctly) can be solved by running the Fix CGI program in the File Manager in User Services. You can use this method or the ones mentioned below to fix most problems.

    Here are some common problems encountered with CGI scripts:

    1. Your script was uploaded in BINARY mode instead of ASCII mode.

      Re-upload the file in ASCII transfer mode in your FTP program. This means the script must actually upload as a 'text' file. If your FTP program automatically puts a ".txt" notation at the end of the script, then simply delete the ".txt" from the file name after you upload it to the server.
    2. The directory your CGI or Perl script lives in is not set to the proper permission. You do not have the directory permissions set to 755.
      ( chmod 755 cgi )
    3. CGI's must have permissions of "755" or they will not execute.
      ( chmod 755 *.cgi )



    Top What are forms and CGI's?

    Forms are blank fields (input boxes, check boxes, radio buttons) on a page which allow browsers to make their selections. To process such selections, it needs to be submitted and parsed by programs on the server. CGI stands for Common Gateway Interface. It is a set of rules (protocols) which sets the basic definitions of how a program should parse these submitted forms.



    Top Does Internet Web Gateway offer any stock CGI scripts?

    Yes, we provide a number of stock CGI scripts FREE to our clients. Read more about the scripts presently available in the Free CGI Library .

    Top How do I implement custom scripts?

    Our servers have the capability to run CGI scripts based on Perl, Unix SH, KSH, CSH, and C/C++ languages. Perl is our language of choice as it is a world standard and is well suited to CGI. In addition, Perl code does not require manual compilations whereas C/C++ code must be compiled on our web servers prior to use.

    If you have a custom CGI script that you need to use, simply upload it to your personal cgi directory. Here are some helpful tips to follow when installing Perl scripts:

    1. Upload to your cgi directory and ensure proper file permission settings
    2. Upload in ASCII transfer mode (NOT BINARY mode)
    3. The first line of each script must read:

      #!/usr/bin/perl

    4. Reference the script using /cgi (NOT /cgi-bin)

    If a script calls another file within your account, but the script does NOT require a URL, you need to use the system path.

    /home/<userid>/HTML/...   <- if the file is in your website root directory
    /home/<userid>/HTML/cgi/...   <- if the file is in your cgi directory

    Substitute the path to the file beginning with your userid. Your userid is the directory name of your account.



    Top Where do I put my CGI scripts?

    Place your CGI scripts (or programs) in your HTML/cgi/ directory. The scripts must have the .cgi extension. We can allow scripts to run in alternate locations. Please contact Internet Web Gateway Support for any special requests. For example, if you had placed a cgi script called surprise.cgi in the directory HTML/cgi/, you access it via: http://www.your_domain.com/cgi/surprise.cgi



    Top How to use feedback forms with our mailer?

    You can generate a simple form by logging in to userservices.your-domain.com and clicking on the feedback form wizard. First you should set up any aliases (email addresses you wish to have the form mailed to) by entering an email address and your ftp password. Now enter your ftp password and click on the generate configuration instructions button. This will generate html code that you can copy and paste into your page (and customize it if you like).

    If you already have an email form, you could use our mailer, which the feedback form uses. To access it, you need at least these lines in the <FORM...> tag of your .html file.

    <FORM ACTION="/cgi-bin/mail.vws?nickname" METHOD="POST">
    Name: <INPUT NAME="from-name" SIZE=30>
    Email: <INPUT NAME="from-email" SIZE=30>
    Subject: <INPUT NAME="subject" SIZE=30>

    <B>Message</B>
    <TEXTAREA NAME="message" ROWS=10 COLS=50>
    </TEXTAREA>
    <INPUT TYPE="submit" VALUE="Send Form">
    <INPUT TYPE="reset" VALUE="Reset Form">
    </FORM>

    Probably the easiest way to build your own email form is to copy and paste the tags above, then add any other information you need from the form.

    It's not essential that the tags be visible to the person browsing your site. If you don't want a particular field to be visible to the browser, but want it to be mailed to you with the rest of the form information, use the TYPE=HIDDEN tag modifier.

    The mail.vws script will take the NAME="from-name" and NAME="from-email" input and add them to the email headers, thus you need to call the Name: and Email: fields as "from-name" and "from-email" respectively.

    Note: nickname is defined in your /home/login-name/HTML/mail.list file (ie. $DOCUMENT_ROOT See: What are environment variables?) in this format:

    nickname:email_address@somedomain.com
    .
    .
    nickname99:another_address@somedomain.com

    Eg.

    support:support@internetwebgateway.com
    sales:sales@internetwebgateway.com
    somebody:somebody@internetwebgateway.com

    Additional Options:

    1. NAME="next-url" - when the form is submitted, this tag will direct browsers to the URL (webpage) specified instead of the default (somewhat ugly) Message Sent page.

      Eg: <INPUT TYPE=HIDDEN NAME="next-url" VALUE="http://yourdomain.com/thankyou.html">

    2. NAME="previous-url" - adding this tag will generate a link to the specified URL on the Message Sent page. While this can really point anywhere, it's usually pointed at the previous page.

      Eg: <INPUT TYPE=HIDDEN NAME="previous-url" VALUE="http://yourdomain.com/somefile.html">

    3. NAME="ignore:values" - adding "ignore:" to a tagname prevents that INPUT from being printed out or sent with the e-mail.

      Eg: To prevent the "subject" from being printed out:
      <INPUT TYPE=TEXT NAME="ignore:subject">

    4. NAME="require:values" - adding "require:" to a tagname will make filling that field required. An error message message will be returned to the browser if the field isn't entered. This is particularly useful for ensuring you get the e-mail address of a form poster.

      Eg. To accept a form only when the e-mail address has been filled:
      E-mail: <INPUT TYPE=TEXT NAME="require:from-email">

      You can combine "require:" and "ignore:", eg. NAME="require:ignore:value"



    Top How to use the stock search engine?

    The search.html file is provided in the HTML/ directory and has all the tags required to access our stock search engine.

    Next, you need to permit that directory to be searchable by our web server by modifying the permission of that directory to "world readable". On Unix prompt, type in this command:

    chmod og+r HTML/sub-directory

    If you want to omit a subdirectory from being listed by the search engine, use the unix command:

    chmod og-r HTML/sub-directory

    Note: This command won't affect the permission of the files in the subdirectory or web browsers looking into the subdirectory of your site.

    Point your web browser and access that search.html page and see the results by typing some word(s) in the search key field and click on the 'search' button.



    Top How to use the stock guestbook?


    The guestbook is automatically setup for all our virtual web clients and it doesn't require any setup or configuration. Access the CGI via: http://www.your-domain.com/cgi-bin/guestbook.pl and a stock guestbook form is generated. This CGI will write to a file called guestbook.html in your HTML/ directory.

    If you do decide to tailor your own guestbook form, create a file with these HTML tags:

    <form method=POST action="/cgi-bin/guestbook.pl">
    <PRE>
    Your Name:<input type=text name="realname" size=41>
    E-Mail:<input type=text name="username" size=41>
    City:<input type=text name="city" size=15> (optional)
    State:<input type=text name="state" size=15> (optional)
    Country:<input type=text name="country" size=15> (optional)
    </PRE>
    Comments/Messages/Blah-Blah-Blah:<br>
    <textarea name="comments" COLS=60 ROWS=4></textarea><p>
    <input type=submit VALUE="Send"> - < input type=reset>
    </form>

    Note: The CGI looks into guestbook.html and searches for the line <!--begin-->. Do NOT remove this line in guestbook.html or else the guestbook won't work.



    Top How do I use the random image generator?

    To implement this random image generator feature, you first have to create a subdirectory in your HTML/ directory, then upload the set of images you wish to randomly display. Say the directory name is called images.

    Next, you need to add this link to your <IMG SRC=....> tag. For the example above, the tag on the page would be as follows:

    <IMG SRC="/cgi-bin/rand_img?images">

    Note: This random images generator will only look for images with .JPG, .GIF extensions and is not case sensitive. You could also use different directories for different sets of random images.

    You could also use this for background images too. For example, I create a directory named HTML/backgif on my web site, after uploading the pictures into the directory, I need to add this link to the <body> tag of the document:

    <BODY BACKGROUND="/cgi-bin/rand_img?backgif">



    Top What are environment variables?

    Environment variables are used when one writes CGI, and it informs the web server where your web site files are located, along with other information about the status of the web site, browsers and log files.

    An important variable is $DOCUMENT_ROOT. This variable tells the web server where the top most directory of your site is located, without which your web site won't work.

    To list what your site's environment variables are, access the stock CGI called test-env in the cgi-bin directory. Eg. http://www.yourdomain.com/cgi-bin/test-env

    Top