Ez Response

Support Area: CGI & Perl


Running CGI and Perl Scripts - Overview
Path Information
Secure CGI
Troubleshooting (those darned "500" errors)

Testing CGi /Perl on your Domain


Running CGI and Perl Scripts - Overview

You have a folder in your account called 'cgi-bin'. It is underneath the '<domain>-www' folder. This is the location for your CGI and Perl scripts. In general, there are a few things that need to be done for your scripts to run properly:

You need the correct location of the Perl executable in your script
See Path information below

You need the proper permissions set for your script file
The permissions should be set at 755 or rwx r-x r-x for your scripts to execute properly. Permissions can be set right in your File Manager screen from the Control Center, or through most FTP programs, including WS_FTP and Fetch. The command is referred to sometimes as "CHMOD" which is the literal Unix command for permission setting.

You need to upload the scripts as ASCII format to the correct folder
Uploading as 'binary' may cause a 500 Internal Server Error

If you will be running any scripts via SSL secure server, you must request that your web host enable that for you.
Just email them and they will get it turned on for you.

Back to top


Path Information

Here are some paths you may require in using your scripts:

Sendmail: /usr/lib/sendmail
Perl: #!/usr/local/bin/perl
Date: /bin/date
Serverpath: /home/username/domain-www/cgi-bin
Root path: /home/username/ (puts you in your the root of your account)
Domain directory: /home/username/domainname-www (puts you in your www directory)
Cgi-bin path: /home/username/domainname-www/cgi-bin/filename (puts you in your cgi-bin)

NOTE: "domainname" means your domain name without the .com at the end or 'www' in front.

Back to top


Secure CGI

If any of your scripts need to run in the secure environment (SSL), you need to request that your web host enable this feature for you. A small adjustment to your account is necessary to be able to access your CGI scripts using the shared SSL certificate. Just put in a request to your web host!

Back to top


Troubleshooting CGI and Perl Scripts

Many times a "500 - Internal Server Error" is generated when a script is improperly set up. Before contacting Support, use this checklist to see what might be causing the problem:
Did you upload the scripts as ASCII format versus Binary?
Did you upload the scripts into the /cgi-bin/ folder?
Did you set permissions for the script to 755?
Did you specify the proper locations of Perl and Sendmail?
If you are running the script through SSL secure server, did you request that your web host enable that feature for you?
Does the file have the correct extension? (.cgi, .pl)
Linux is case-sensitive. Did you make sure to link to files using the *exact* spelling, including case?
Are there any extraneous characters in the script (extra carriage returns at the end, extra spaces, etc)? This can happen if you used WYSIWYG editors such as Microsoft Word or even WordPad to edit your script. They often place extra characters in the file. You should always use plain-text editor to create and/or edit your scripts to avoid this situation.

Testing CGI/Perl on your domain account

Here is a very basic 3-line script written in Perl. Copy the text below into Notepad, or other text editor. Using ASCII format, place it into your cgi-bin folder, and name it 'test.cgi'. Set permissions to 755 (rwx rx rx), and launch it in your browser by going to "www.<yourdomain.com>/cgi-bin/test.cgi".

You should see a line of text saying "Hello world!" if it works properly. NOTE: if the test script works, then the problem is not with your server or your domain account, it is in your script. See the troubleshooting checklist above and review your steps.

-- snip below this line --
#!/usr/local/bin/perl
print "Content-Type: text/html\n\n";
print "Hello world!\n";
-- snip above this line --

IMPORTANT NOTES ABOUT THE TEST SCRIPT!
The file size of the tester script should be exactly 82 bytes. If it is any more you may have an extra space or carriage return, which will cause the test script to return a 500 error. THIS DOES NOT MEAN CGI IS BROKEN FOR YOUR ACCOUNT! You can remove the spaces or carriage returns in the File Manager tool by clicking on the file name - it will bring up an edit window. Many Windows-based programs can generate the extra characters - including Notepad. The best way to install this test script is to use the File Manager tool to create the file 'test.cgi' in your 'domain-www/cgi-bin' folder and paste the above script into it. Verify it has 82 bytes, and that you set the permissions to 755 (rwx r-x r-x).

Back to top

Google
 
Web Ez-Response Search