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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script runs from command-line, but...

Status
Not open for further replies.

newDBA

MIS
Nov 8, 2001
21
FR
I have a PERL script that runs fine from the command-line. But when I run it over the web, it stops when I try to do the file I/O. I don't see any error messages, it just stops.

This is the script:
Code:
use strict;

print "HTTP/1.0 200 OK\n";
print "Content-Type: text/html\n\n";

print "<HTML>\n";
print "<BODY>\n";
print "<H4>Hello World</H4>\n";

open (OUTFILE, ">> C:/Dev/perl/cgi-bin/file.out") or die "Unable to open file.\n";
print OUTFILE "testing...\n";
close (OUTFILE);

print "</BODY>\n";
print "</HTML>\n";
The web server is IIS 5. Any suggestions?

Thanks.
 
remove this line and try again:

print "HTTP/1.0 200 OK\n";
 
use CGI::Carp qw /fatalsToBrowser/; can be invaluable in situations like this.

Also check your webserver's error logs, chances are it's a "premature end of script header" message, it's because you're outputting text to the browser without sending a http header first.

I'd also like to suggest using CGI.pm to roll your headers

Code:
use CGI;
$q=new CGI;
print $q->header();

This will always print the correct header, a common source of errors for a lot of web side perl scripting, just a thought, not an imperative ;)

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
The CGI::Carp addition was great...I'm now seeing a "Software error". Thanks!!
 
If you tell us what the error is we might be able to assist.

CGI::Carp is so the errors are sent to the browser to save you looking for the weblogs

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
I needed to grant the IWAM_${machinename} user read & execute permission on a directory (I'm using IIS). It's working now.

Thanks again.
 
Could you post the actual error?
It may help someone coming after

Thanks
--Paul

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top