Running Scripts on Your Site

To add interactivity to your site, you might want to implement scripts (shell, C, or perl) on your site. Many scripts are freely available throughout the web and through other resources. However, there are several parameters which need to be set to enable the scripts to run.

Most of these scripts come with extensive documentation. The documentation describes the configuration certain lines in the script itself to enable it to work on your particular host machine, and often needs to know the location of certain programs on the server. The following information will be required:

  • Location of perl: /usr/bin/perl
    This appears on the very first line of your perl script.

  • Location of sendmail wrapper: /usr/bin/sendmail

  • Upload location:
    Put your scripts in public_html/cgi-bin

  • Call for script:
    This must be the call for your particular script from the page that calls it.

  • Setting Permissions
    Once your script is uploaded, it must be set so you can run it. There are different ways of achieving this. If you are using an FTP program such as WS FTP, select the uploaded file, and right click it. Then select chmod UNIX from the menu, and then a dialog box will pop up with permissions. Click the checkboxes to select permissions as shown in Figure 1.

    WSFTP Chmod Dialog
    Figure 1

    • Owner: That is you. You want to be able to read, write, and execute this script.

      Group: In Unix, the group is traditionally users you share files with. On this server, it is our other customers who have accouts on this machine. You don't want them to be able to write to your script.

      Other: In Unix, this is 'the rest of the world.' This includes the httpd's unpriviledged user, "nobody" who reads and serves web pages to the rest of the world. They, too, should not be able to write to the script.

    Setting Permissions From The Command Line
    The other way to set permissions (chmod) is to log into your shell account, go into the directory your perl script is in (public_html/cgi-bin) and then type the following:

    chmod 755 scriptname.ext

    Other Files Associated With Your Script
    Your script might write to an actual page on your site. If that is the case, you will need to set permissions to that particular file so you can write to it, as well as read and execute it. Such files should be set 755 if you want web visitors to be able to read them, 700 otherwise. Setting them world or group writable is not required, thanks to our cgi wrapper. Most script documentation that states to make files world writable may be ignored. A word to the wise: Not all scripts are well-documented. If you are having trouble getting a script to run, check your permissions and determine if the script is writing to another file, and whether or not the directory the file needs to be in actually exists. Also, a few scripts, regrettably, are confused by wrappers, and may need reprogramming.

    Again, in WSFTP, right click on the uploaded file, select CHMOD (Unix) and click the appropriate checkboxes in the dialog box.

    Return to support index.

    Return to home.