CodeMyster Posted February 7, 2005 Share Posted February 7, 2005 Hi all, Ok first off lemme say I cant be happier with TCH hosting, my only regret was not moving servers sooner! I love the support and features and have been having a ball setting up my new site. That said, I have a minor issue. I've reached a point the highend site functionality is up and working but some of my custom PERL scripts I used with the previous host wont execute. The file is CHMod'd 755. In true programmer fashion I kept simplifying the script till I cant go any simplier. So here is the basic test script I'm down to: #!/usr/bin/perl########################################## ########################################## # # # Test # # # ########################################## ########################################## print "<html>"; print "<head>Header</head><body>"; print "<font size=6> Hello World!</font>"; print "</body></html> http://www.huntingnut.com/cgi-bin/zz.pl Something like this worked great before but gives an error here at TCH. It makes me suspect something outside of my control is causing the error. Once I can execute this stupidly simple script I can begin to fix the dozen or so other scripts I have left to port over. Any ideas / help? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
TCH-RobertM Posted February 7, 2005 Share Posted February 7, 2005 It could be the path to perl try this /usr/local/bin/perl and Welcome to the forums Quote Link to comment Share on other sites More sharing options...
schussat Posted February 7, 2005 Share Posted February 7, 2005 It doesn't look your script is sending a header. If you add a line to >print "Content-type: text/html"; does it work any better? Also, your code excerpt needs a closing quote and semicolon -- but I'm guessing those just got snipped when you posted it. Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted February 7, 2005 Share Posted February 7, 2005 Welcome to the forums CodeMyster! Yes, you need to send the headers to get it to work. Quote Link to comment Share on other sites More sharing options...
TCH-RobertM Posted February 8, 2005 Share Posted February 8, 2005 In my previous post I was mistaken about the perl path it should be /usr/bin/perl as you had it in your script. Sorry if this caused you any time loss. RobertM Quote Link to comment Share on other sites More sharing options...
CodeMyster Posted February 8, 2005 Author Share Posted February 8, 2005 Ok thanks for the help and ideas so far. Yes part of my initial script was clipped in the quote. I also tried changing the perl directory to /usr/local/bin/perl but that didnt do anything. The path in the cpanel shows it to be /usr/bin/perl. Good catch on the print "Content-type: text/html"; ... the original script I'm trying to get working had it, my sample did not. I did some more digging into error logs and determined it to be a 500 error: Premature end of script headers. Yea these suck Here is my current script that errors out: #!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html"; print "<html>"; print "<head>Header</head><body>"; print "<font size=6> Hello World!</font>"; print "</body></html>"; (http://www.huntingnut.com/cgi-bin/zz.pl) There is very very little to go wrong here. In fact if I delete it all but the #!/usr/bin/perl it will still error. As I said, I've also tried #!/usr/local/bin/perl with the same results. THIS STRONGLY MAKES ME SUSPECT THE PATH IS INCORRECT. Cpanel shows the path to be #!/usr/bin/perl ... /shrug I verified via 2 different apps I was uploading the file in Ascii Mode. I even went as far as deleting the file, creating it through cpanel, editing it and putting back in the code. Nada. CHMODs are correct (755) I've written quite a few PERL scripts so its not like I'm a total newbie at this, but darned if I can see what is wrong. Guess I could re-write everything in PHP but that poses problems of its own as its tricker to integrate into CPGNuke, I'm learning PhP quickly but it would still take some time before the old systems were up and functional again. I did alot of searching around here in the forums and I see ALOT of people who had this same issue. There are a ton of Support peeps saying "I'm not a perl expert but hang in there, someone will help", then a few pieces of advice but I've yet to see a post here where someone really said they had a similar issue that was cleared up by fixing something minor. I dunno... I've tried about every permutation I can think of... running out of ideas quickly though. Quote Link to comment Share on other sites More sharing options...
curtis Posted February 8, 2005 Share Posted February 8, 2005 I have your original snippet working Here Ionly modified one line. >#!/usr/bin/perl ########################################## ########################################## # # # Test # # # ########################################## ########################################## print "Content-type: text/html\n\n"; print "<html>"; print "<head>Header</head><body>"; print "<font size=6> Hello World!</font>"; print "</body></html>"; Notice the *new line commands (\n) at the end of the Content-type line. This line must be followed by a blank line which is why there are two new line commands (\n) included. The first one goes to the next line, the second puts a blank line after it. Hope this helps Quote Link to comment Share on other sites More sharing options...
TCH-RobertM Posted February 8, 2005 Share Posted February 8, 2005 Curtis Thank you for helping out here I was looking at this link when you posted that Perlhelp I was testing with this script >#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/plain\n\n"; print CGI::Carp->VERSION, "\n"; and have it working Here Hope this helps Quote Link to comment Share on other sites More sharing options...
CodeMyster Posted February 8, 2005 Author Share Posted February 8, 2005 Ok thanks all... not sure why this was such a pain in the rear. My original scripts came from a site that was up and running for 5 years... I updated the local paths and it was 500 errors forever. I started gutting huge chunks of it to simply the problem and guess I removed 1 too many lines along the way lol. The header stuff above worked as does this: #!/usr/bin/perl -wuse CGI qw(:standard); use strict; print header; print "Hello World!"; print header does all the CGI / HTML in a single call. Soooooooooooooooooo thanks for the help. I wrote most of my scripts 4 to 5 years ago and in looking them over today... I really need to rewrite it all in php I guess with SQL dbase support over the clunky flat system I used before. /thank Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted February 8, 2005 Share Posted February 8, 2005 Good catch Curtis! Quote Link to comment Share on other sites More sharing options...
mitten Posted September 12, 2005 Share Posted September 12, 2005 (edited) I'm brand new to this scripting stuff - do I have to do something special to enable it on my site? I've tried copying these little snippets posted in this thread to text files, uploading them into my cgi-bin folder, but I get 500 errors when I try to run them. This one contains the 'hello world' snippet (from curtis's post) from above: http://martinirepublic.com/cgi-bin/test.pl What am I doing wrong? (My eventual goal is to run a little one-time script that will copy some database fields into new database fields so I can migrate from one CMS to another.) Edited September 12, 2005 by mitten Quote Link to comment Share on other sites More sharing options...
mitten Posted September 12, 2005 Share Posted September 12, 2005 (edited) DOH! needed to change the permissions... Edited September 12, 2005 by mitten Quote Link to comment Share on other sites More sharing options...
mitten Posted September 12, 2005 Share Posted September 12, 2005 Ok, so the little snippet works, but the real script is still giving a 500 error. Is there a way for me to see more information about the error? Like what generated it and where? Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted September 12, 2005 Share Posted September 12, 2005 Check your error log in cPanel. It should give some clues as to what went wrong. Most of the time it is the file was uploaded in binary format when it should have been uploaded in ASCII and the permissions are not changed to be executed. 755 is the proper permissions on most perl scripts. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.