I can not run any script through the browser but I can run in shell.
Then occasionally I am able to (intermittently) run a test script in the browser, then try to run another of my scripts and get a 500 error. When I return to the script that DID run ok, I then get a 500 error again.
Can anyone please shed some light? I am at wit's end, of course, as I have run these scripts for 5 years on a different server and am just having trouble on this new server. On Sunday everything ran ok, on Monday everything was broken!
Put this near the top of your perl scripts
use CGI::Carp qw (fatalsToBrowser);
That will start to print errors to the screen.
In your apache config, turn on error logging and start watching the log files generated.
As for permissions - double check with your host as to the right permissions for your server box setup. It could be something nonstandard.
Also double check that the act used to upload the scripts. Can the web server execute scripts by that user?
I can not even run a test.pl script with simple code:
#!/usr/bin/perl
print "Content-Type: text/html";
print "<HTML><HEAD>";
print "<TITLE>CGI Test</TITLE>";
print "</HEAD>";
print "<BODY><H2>I just wrote a web page using Perl!</H2>";
print "</BODY></HTML>";
Where would I put the CGI::Carp qw (fatalsToBrowser);? as I tried and I still get a 500 error. I have the error logging on and I get only
[Thu Mar 1 06:06:13 2007] [error] [client 203.113.232.248] Premature end of script headers:
Driving me bonkers!
I have a test directory with nothing but .pl and .cgi files in it called /test. The server is set up as such through a webhosting panel:
CGI aliases
.cgi
.pl
CGI dir aliases
/test -> /test
/cgi-bin -> /cgi-bin
Still unable to run even that simple .pl file. I am not exactly sure what to ask the host to do. I have put in a support ticket saying that I am not able to run simple scripts. No response -- that was 5 hours ago.
but I can run in shell
Try this. Navigate to the directory of the script,
cd /var/www/html/cgi-bin
or whatever. Make SURE you are in the right directory,
ls -a
Now execute a command line editor,
nano test.pl
or
pico test.pl
or .cgi, or whatever. If you see a blank screen, you got the filename wrong, CTRL-X to exit and try again. For either of these, once you see the script in the editor window, press CTRL-O (letter O) to write out, press enter to overwrite the script. CTRL-X to exit.
Try calling the script now. If it works, here is what I suspect: your text editor is saving PC style end-of-line characters. I learned long ago to always use an editor that has the capability to save in Unix format. Then when you upload in ASCII, no problems. I started off with HTMLed, which has zero support and limited use as an HTML editor, and now exclusively use HomeSite.
If it does not, try
#!/usr/local/bin/perl
Although by the sounds of it you have the path to perl right, you got it to work once. I'm betting on the end-of-line characters.
And of course chmod 755 [filename.] :-)
And by the way zuzu_jane, welcome aboard! (Shame on you Mr, Tabke. :-) )
Should I be asking the server host to set some permissions that I haven't got access to change?
I have done the usual trouble shooting -- carriage returns, correct permissions, execute the script in the shell etc etc to no avail. It was frustrating enough for me to post here for some expert help. The simple little test scripts won't even run.
Appreciate all the help and I will update after the Apache upgrade.
I had 6 days of agonising chmod, checking scripts etc etc etc but it seems to be ok now. Thanks all for your replies and help.
zuzu jane