Step by step: installing a CGI script


First of all you must have an access to the server. Then you must be allowed to install CGI scripts. After writing your CGI script you have to:
  1. Check where the PERL interpreter (if you wrote a PERL script) is located and where the SENDMAIL program is located on your server
  2. Ask to your system administrator where you have to put your script (for example inside of the 'cgi-bin' directory)
  3. Upload your script
  4. Change file permissions by means of the 'chmod' command or by means of your FTP client

Step 1: where is the PERL interpreter?

If you write a script by means of the Bourne shell language, you haven't to think about PERL. But if you wrote a PERL script, you have to know where the interpreter is located. Usually the PERL is located inside of the '/usr/bin' directory (on Unix systems) but your system could have a different configuration. So you have ask to your system administrator. Besides you have to know where the SENDMAIL program is located.

Step 2: where have you to put your script?

Depending on the server configuration, you could have to write just a file with the 'cgi' suffix or you could have to put your script inside a particular directory. Usually the assigned directory is: 'cgi-bin'.

Step 3: upload your script

Ok, now you have all information you need, and you have to uplod your script. First rule: you have to upload your script by using the ASCII mode. You could have problems if you upload it by using the BINARY mode. For example: the newline character is an ASCII coded symbol, so your FTP client has to transfer the script by using the ASCII code system. If you use BINARY mode, the newline character will be bad translated.

Step 4: change file permissions

You have to change file permissions, because your script must be executable. On Unix systems the 'chmod' command change file permissions. Permissions are: 'r' (reading), 'w' (writing) and 'x' (execution). So you have to use the 'x' flag. You can enable operations by means of a '+' symbol and disable operations by means of a '-' symbol. As you have to enable execution, the 'chmod' command will be: 'chmod +x scryptname.cgi' (in this case you are allowing execution of scriptname.cgi for all users. However if your server is running using your own UID (User IDentifier) you have to change the chmod command so:
'chmod u +x scriptname.cgi'. In fact in the first example you are supposing that your server is running as 'nobody' (and all users should be allowed to execute the script), while in the second example your server is running using your own UID.


Index           Home  Back       About  Contact us!

Copyright (c) 1998-2006 Wowarea