saint Posted September 22, 2009 Posted September 22, 2009 Hi I've got a little problem with all my perl/cgi scripts, basically doesn't matter what I put in my script it always ends up with 500 Internal Server Error. My test script looks like this: #!/usr/bin/perl # use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard); BEGIN { my $homedir = ( getpwuid($>) )[7]; my @user_include; foreach my $path (@INC) { if ( -d $homedir . '/perl' . $path ) { push @user_include, $homedir . '/perl' . $path; } } unshift @INC, @user_include; } $|=1; # Flush output immediately. print header; print "Hello, world!\n"; Run it here: http://instalekt.heliohost.org/cgi-bin/t.pl or http://instalekt.heliohost.org/cgi-bin/t.cgi File permissions are set to 755, and CGI perl modules are installed. File tested as both .pl and .cgi in cgi-bin direcotory. I've run this script on my Apache+ActivePerl server and the it works just fine (without the BEGIN). I've uploaded both files using Total Commander no change then through cPanel still the same. The Error log in cPanel only shows: [Tue Sep 22 11:56:59 2009] [error] [client *.*.*.*] File does not exist: /home/instalek/public_html/500.shtmlwhich doesn't have anything to do with my problem. Can anyone help me, what am I doing wrong?
Byron Posted September 22, 2009 Posted September 22, 2009 This executes fine for me. http://instalekt.heliohost.org/cgi-bin/t.cgi Here's a script you can try. http://byrondallas.heliohost.org/cgi-bin/time.txt http://byrondallas.heliohost.org/cgi-bin/time.pl You can try adding this to your script and see if it prints any errors. # This is used for debugging. All errors are # written to errors.txt, if any. BEGIN { use CGI::Carp qw(carpout); use diagnostics; open(LOG, ">errors.txt"); carpout(LOG); close(LOG); }
saint Posted September 22, 2009 Author Posted September 22, 2009 You are right t.cgi is working now, don't know why it didn't but when I download it change name and upload it doesn't work. I've use your code +shebang, and permissions set to 755, and we're back to the beginning (error 500, and errors.txt wasn't created). Ok now I have no idea what this is about, I've tried uploading t.cgi again with Total Commander and cPanel, editing it both with Notepad++ (utf8 + UNIX then WINDOWS) and with cPanel editor and nothing it's just broken, again.
saint Posted September 22, 2009 Author Posted September 22, 2009 Sorry doesn't work for me: the one with #comment >> http://instalekt.heliohost.org/cgi-bin/t3.cgi no comment >> http://instalekt.heliohost.org/cgi-bin/t2.cgi still no http://instalekt.heliohost.org/cgi-bin/errors.txt I've used your test.txt saved it and rename Update: looks like server needs some time before it can run new script, the t3.cgi started to produce an error and errors.txt file after about 5 minutes from the first run Update2: I think the problem is character encoding if I use us-ansii for encoding it works, problem starts with uft-8 (and I need to use it since my scripts will contain special characters non-us) Now I know I have to edit the code through cPanel editor and set utf-8 even thow the cgi file is save as utf-8, strange but it works
saint Posted September 22, 2009 Author Posted September 22, 2009 I can see text files in cgi-bin just fine. The problem was encoding as mentioned above, I'm using utf-8 the server is using us-ascii, anyway thanks for the help. I've managed to make it work thanks to your errors.txt there were no special characters in this line so I knew there must be some kind of a encoding problem.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now