Details for running Perl scripts on our shared servers.
- Installing Scripts
- Command Locations
- Editing your Scripts
- Standard Error Messages
The first step to installing a cgi script is to upload the script into your account. It doesn't matter where you place the script, it will execute properly from any directory. However, creating a directory called scripts may help you keep some order to your files.
Please note: You can not call your cgi folder cgi-bin. This is the name of our cgi folder and any request from your web page for a directory called cgi-bin will result in a 404/file not found error.
Make sure the files have the correct .cgi file extension. A .html extension will not work. Some custom scripts may have a .pl extension, that's ok, but note, if you are calling a script from a page on your website, you must rename the file and give it that .cgi extension. If you attempt to call a script with a .pl extension from your website you will receive a Method not allowed error.
When uploading your scripts, please make sure that you upload in ASCII mode. If you mistakenly upload your scripts in Binary format, invisible characters may be saved with in the script itself. If this occurs you will get a 500 Internal Server Error message when you attempt to run the script.
You will also need to make sure that your scripts have the correct file permissions. You may alter the permissions on any file or folder in the file manager of your /admin area. Your scripts must be executable. Try the numerical value 755. It is also important to check on the permissions of the directory holding your cgi scripts. If a directory is either group or world writable, this may lead to a potential security hole, and the script will not execute. The ideal settings for a directory is the octal value 711. If the permission on your scripts or your cgi directory are set incorrectly, you will receive a 500 Internal Server Error message.
The first line of ALL cgi scripts should read:
That said, the the path to Perl is:
If you are having problems executing the script, it could be do to invisible characters surrounding the above line. This is caused most often when saving files in windows with line feeds or when uploading scripts through FTP in binary format. The best way to clear up this problems is to delete the first line and rewrite it.
Should you need to supply a script with your "home directory", "base directory" or "full server path", the value that you enter should look like this:
The mail command may be found at:
The sendmail command is located at:
The date command may be found at:
PLEASE NOTE: the list below is incomplete, so if you do not see the module you'd like, please use contact us.
Once uploaded into your account, you may use your file manager's editor to make changes to your custom scripts. This is important: When editing perl scripts make sure that you have wrapping turned OFF This will help insure that the syntax of you perl script remains intact while you are editing. You can turn wrapping on and off in the /admin area under Options and then Password and Interface. If you leave wrapping on without fail you will receive a 500 Internal Server error when you run the script.
Once you are done editing, you may want to check that the perl syntax is in good shape. You will notice that your text editor has the option of Check Perl Syntax The perl checker tests for syntax errors in your perl code. Ideally you will receive a message that says syntax ok If there are syntax errors with in your script you will receive some frightfully vague error messages. We didn't write this program so cant help that part. Vague as these error messages may be, they generally do include a line number, so you are often pointed in the right direction for trouble shooting. If you take a look and cannot understand what the perl checker is saying, send us a note with the error and the name of the script in question and we will take a look. As always. please include your account username in your correspondence.
Make sure your cgi directory is not called cgi-bin. This is the name of our cgi folder. try the name "cgi", scripts", "cgibin" or "cgi_bin"
Double check the url or path you use to call your script. Are you reference the correct location and file name? Please remember that location and file names on our servers are case sensitive.
Make sure that the script you are calling has a .cgi file extension.
This is a toughie. There are countless reason for this error. There are just a few things to keep in mind:
- Make sure that the first line of any perl script reads #!/usr/bin/perl
- Make sure that your scripts are uploaded in ASCII format
- Check your file permissions. Files should be set to 755, your scripts directory to 711
- All cgi scripts need to print a content type. If you have a pre written script, it will must likely include this command, but if you are writing you own please make sure that you include the following line:
print "Content-type: text/htmlnn";
- Make sure there are not syntax errors in your script. Make sure you have wrapping in your file manager editor turned off (see above instructions) and run a perl check. See if you get any errors.
- And finally, despite a "syntax ok" message form the perl checker, there may simply be errors in the code. Drop us a note with the following information:
- Your account username
- Your account domain name
- The location of the file in your account
- The HTML page that calls the script
and we will take a look at it for you.