?
Solved

Suggestions: perl/cgi on apache:linux...problems running script from browser, works fine from command line

Posted on 2003-10-22
9
Medium Priority
?
283 Views
Last Modified: 2010-03-04
My setup is Apache, Linux, Perl.

I'm running RH9 with a new standard install of all required tools (perl, mysql, php, etc.)

the issue im having is trying to get the scripts to run from the browser...all i get is internal server error...i check the logs and most of the time all i see is premature end of headers. if i issue the command "perl anyscript.cgi" from the command line it works/generates desired html code. ive double checked permissions and syntax and am a stand still at this point.

does this sound like a httpd.conf issue?

fyi: the scripts do work, ive run them successfully on my sun box.

any suggestions?

thanks-neil
0
Comment
Question by:nriddock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 3

Expert Comment

by:prady_21
ID: 9604913
premature end of headers- u get this error when there is information being passed to the browser before the headers are being passed

programs run on solaris successfully need not run successfully on linux
0
 
LVL 8

Expert Comment

by:heskyttberg
ID: 9605801
 print "Content-type: text/html\n\n";

On linux, make sure this is the first line in your perl scripts.
If shell script just translate print into echo.

Regards
/Hasse
0
 

Author Comment

by:nriddock
ID: 9606321
does the print command go before or after the #!/usr/bin/perl?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 2

Expert Comment

by:j_dyer
ID: 9607311
The print command goes after the #!... so, you use:

#!/usr/bin/perl

print "Content-type: text/html\n\n";  # Make sure you have to \n's here - very important!

### Rest of script here.
0
 

Author Comment

by:nriddock
ID: 9608023
tried that...it's still erroring out...any other suggestions?

does this sound like an apache issue (httpd.conf) or more of a script/syntax issue?

thanks
0
 
LVL 2

Accepted Solution

by:
j_dyer earned 2000 total points
ID: 9608165
I'd be inclined to get a bit more error reporting from the script.
Try:

#!/usr/bin/perl -w

use strict;

print "Content-type: text/html\n\n";
...

and see if any more errors appear.
Note, your script may generate loads of warnings when you run with strict enabled, if it's too
must to cope with, try without the strict, and just see what the -w flag gives you.

It sounds to me like a script problem, rather than an issue with your httpd conf (though you never
know for sure until it works...)
0
 
LVL 2

Expert Comment

by:j_dyer
ID: 9608209
just an afterthought...in my experience, there errors are normally caused quite early on in the execution
of a script, often by a require statement. It might be worthwhile just pasting the first few lines of the
script in question (say 20-30) - I might be able to spot something obvious straightaway.
0
 

Author Comment

by:nriddock
ID: 9609711
that did it...

#!/usr/bin/perl -w


the "-w" seemed to make all the difference. what exactly does the W do?

the use strict seemed to cause errors so i removed it. Thanks for all your help. Enjoy the extra points.

-Neil
0
 
LVL 2

Expert Comment

by:j_dyer
ID: 9612738
-w basically enables warnings, which makes troubleshooting perl problems *far* easier.
use strict makes perl 'paranoid' - things have to be 'right' for the script to execute without
generating errors ie:
$x = 10; # will give an error, since x has not been declared but...
my $x = 10; # will not give an error, since x has been declared

As the perl manpage says in the 'bugs' section - 'The -w switch is not mandatory'...you should
always use it when running perl.

Thanks for the extra points.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question