Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl on redhat 9

Status
Not open for further replies.

Zippyflyer

Technical User
Aug 17, 2003
44
US
totally new to linux, perl scripts give me a 500 error but my path is #!/usr/bin/perl and that file does exist on my install, redhat 9 w/ gnome desktop and server install
any help would be appreciated
 
sounds pretty generic, check for executable permissions for the user the web server is running under. Failing that, check the FAQ's here and maybe in the CGI forum, as they touch up on other things. Also, dig up the error log and see what it's writing there, as that's always much more helpful information.

________________________________________
Andrew
 
the script and the perl program all have executeable permissions, the error log has 1 line that isnt much help "premature end of headers
 
premature end of headers"

it means exactly what is says

Apache is your webserver I'll assume using RH, and is very unforgiving about what you output to a browser unless a header has been written

Code:
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "Hello World";

if your script is using CGI.pm, then there's much nicer ways of generating your headers, and because it's a module, if there are developments in headers, then it should have them by next release


Try the short script above, and if that works, it's the header, if not post back some code up until the first two/three output statements

HTH
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
still got the server error on the simple test script, the script in question is 1 ive used before with no problems on a windows apache server with modperl installed. its just when i transfered to linux all the scripts stopped workin.
 
sry for the double post but same error log statement for the test script (diddnt see edit post option)
 
try running the test script at the command line on the server, and see what that outputs, cause that's whats causing the server to send your browser the prem end headers

--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
Transfer from windows to linux? I'm gonna have to guess newlines are confusing linux's shebang read. Run that test as "./script.pl" insteadl of "perl script.pl" if you would.

perl -ni 's/\r\n/\n/g' *.cgi *.pl

________________________________________
Andrew
 
well i got a simple hello world script to function now, but when i use a premade script for a message board (cutecast) i still get the 500 error with premature end of headers. This script as i mentioned worked fine on window but since im trying to phase out windows i want to get it working on linux,
their site says it is possible, but all the help on their site says its a bad ascii transfer thats doing this, i dont ftp it over so im at a loss as what to do about it. when i try and run that script from command line it says not found even though a dir command shows it.

the hello world script that works for me is
Code:
#!/usr/bin/perl

     # Tell perl to send a html header.
     # So your browser gets the output
     # rather then <stdout>(command line
     # on the server.)
print "Content-type: text/html\n\n";

     # print your basic html tags.
     # and the content of them.
print "<html><head><title>Hello World!! </title></head>\n";
print "<body><h1>Hello world</h1></body></html>\n";
 
bad ascii transfer" means something more like "didn't transfer in ascii mode". So if you didn't even ftp it over, then it was never transferred in ascii mode. The newlines have to be converted for the *nix system to properly read the first line of the script, and the ftp transfer mode is just the easiest way to do the conversion since that's how most people transfer the files over.

What's the exact message it gives you when you run it from the command line? Is it something like "interpreter not found"? Could you run "od -a script.pl | head" on a script that doesn't work and post the results?

________________________________________
Andrew
 
Code:
000000   #   !   /   u   s   r   /   b   i   n   /   p   e   r   l  nl
0000020  nl   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #
0000040   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #
*
0000120   #   #   #   #  nl   #  sp  sp  sp  sp  sp  sp  sp  sp  sp  sp
0000140  sp  sp  sp  sp  sp  sp  sp  sp  sp  sp  sp  sp  sp  sp  sp  sp
*
0000220  sp  sp  sp  sp  sp  sp  sp   #  nl   #  sp   C   u   t   e   C
0000240   a   s   t   (   R   )  sp   v   2   .   0  sp   B   e   t   a
0000260  sp   -  sp   A  sp   b   u   l   l   e   t   i   n  sp   b   o
 
Zippy - if you transfer it over using ftp in ascii mode it should fix your problems. Ftp does the new-line translation for you no problem - people are wary about using ftp sometimes because it *can* do that conversion on files you don't want changing - but in this case you do so ftp will be fine.

Mike

"Deliver me from the bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
thnx is there any way to avoid ftp i dont want the hassle of setting one up, or do you have a link to a step by step for setting up vsftpd with a named user account?
 
Them be *nix newline, so that's not your problem and I'll stop harping on it. :)

So back to the basics, your error log on the webserver says nothing more than "Premature end of script headers"? When you run the script from the command line, you get "not found" ? Anything more to the error message, hopefully?

________________________________________
Andrew
 
it now has two errors
[Mon Sep 20 16:59:40 2004] [error] [client 24.118.198.88] mod_mime_magic: can't read `/var/[Mon Sep 20 16:59:42 2004] [error] [client 24.118.198.88] Premature end of script headers: cutecast.pl
 
running from command line now works, and produces:

Code:
./cutecast.pl: line 1: !#usr/bin/perl: No such file or directory
./cutecast.pl: line 34: =: command not found
./cutecast.pl: line 38: =: command not found
./cutecast.pl: line 39: =: command not found
./cutecast.pl: line 40: =: command not found
./cutecast.pl: line 41: =: command not found
./cutecast.pl: line 42: =: command not found
./cutecast.pl: line 43: =: command not found
./cutecast.pl: line 44: =: command not found
./cutecast.pl: line 45: =: command not found
./cutecast.pl: line 46: =: command not found
./cutecast.pl: line 47: require: command not found
./cutecast.pl: line 48: require: command not found
./cutecast.pl: line 49: require: command not found
./cutecast.pl: line 50: require: command not found
./cutecast.pl: line 51: syntax error near unexpected token `&'
./cutecast.pl: line 51: `&decode_input;'
 
!#/usr/bin/perl

--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
ya saw that last night and fixed it, same errors though
 
philote, well spotted but you knew what I meant ... didn't you

;-)

#!/usr/bin/perl is what you need, not what I rapped up last night

--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top