My CGI script is not working! It worked fine until I uploaded a new copy. What’s going on?

Question:

I have a perl cgi script that is not working. I’m sure I have the chmod settings correct and their are no syntax errors.

Answer:

Unfortunatly there can be many different reasons why a script stops working. The most common is that you made a recent edit to the file that broke it. If you are sure that you did not make any syntax (aka programming) errors in the script, the following may help:

When you upload a script (cgi, perl files, etc.) from a windows computer to a unix-based server, you need to upload them in ascii mode. If not, windows adds some extra control characters at the end of each line that cause the script to not run correctly. Normally your FTP program will switch the mode in the background for you. Sometimes it does not though.

In the future, you can just manually hit the ascii mode switch in your FTP program to make it upload the script in ascii mode. The best mode to keep your FTP program in is usally labeld as “auto”. Keep in mind that in your particular FTP program it may be labeled differently. Each FTP program uses their own terminology.

Most ftp programs in auto mode will do the right thing for each file you upload.

Leave a Reply

Your email address will not be published. Required fields are marked *