Jump to content

Perl Script Execution


CodeMyster

Recommended Posts

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!

Link to comment
Share on other sites

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.

 

 

:)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 -w

use 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

 

:D

Link to comment
Share on other sites

  • 7 months later...

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 by mitten
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...