I hope this is the right section for this, but I've been looking into using Perl to create a few sites (bascially just to broaden my knowledge) and having some issues with running the scripts. If I execute the script through the terminal window (PuTTY) it returns fine, however if I run it through a browser I get a 500 error. I've got through so many different tutorials but none have helped me. I've been making sure I chmod the files to the correct setting. Made sure I have the right settings in my Apache config and installed the mod_perl module. Nothing seems to work though... The errors I'm getting in my error log are: [Thu Nov 05 18:54:54 2009] [error] [client 86.16.187.70] (2)No such file or directory: exec of '/dir/to/file/test.cgi' failed [Thu Nov 05 18:54:54 2009] [error] [client 86.16.187.70] Premature end of script headers: test.cgi Code (markup): Any one got any ideas what is going on?
The error message indicates a "file not found" error. When you run a cgi script from a website, the root path may be different than when you use SSH via PuTTY. Check that first. Second, scripts run via CGI need to output proper MIME-type headers before any other output or you'll get an error. That is, you should have something like: print "Content-type: text/html\n\n"; Code (markup): near the start of your code.
I'm not sure how the root path can be different between the two...? I tried printing out the content-type line but didn't help at all.
What happens if I have saved the file in something other than UNIX format? I just read a couple more articles and realised my editor probably automatically saved it in DOS format.
Also, if you're uploading it via ftp, make sure you've got the upload type set to ASCII. It's kind of the same thing as the DOS setting in the text editor.
FTP isn't an issue, I'm saving directly to the server using Samba. So does that mean the DOS thing is quite a likely cause?
Thanks for the help, that was the problem. As soon as I saved it in UNIX and re-CHMOD-ed it, it worked fine.
Damn, so that's why I was having the same problem! Some files worked and others gave this error, I couldn't figure out why since they were very similar. Thanks!