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

Called Perl script dies immediately -- how to find out why?

Status
Not open for further replies.

gnubie

Programmer
Apr 16, 2002
103
US
On Submit, an HTML FORM action calls a perl script. The script is found, but dies immediately. A DOS window opens briefly and disappears too quick to read.

The call:
<FORM METHOD="POST" ACTION="cgi-bin/managelists.pl">

I'm also using:
print "Content-type: text/html\n\n"; and fatalsToBrowser

in the script.

Apache server log shows no errors.

Can I make the DOS window hang around?

Other ideas?

 
Is your web server configured for perl?


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
post the start of your script, and what webserver are you using?

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Sorry, I should have included the shbang line. Here is the beginning of the script


#!/usr/bin/perl
#
# Manage the lists
print "Content-type: text/html\n\n";
use CGI::Carp qw(fatalsToBrowser set_message);
BEGIN {
sub handle_errors {
my $msg = shift;
$msg=~s/\.\s/\.<br><br>/g;
print <<EOE;
<div style="margin-left: 5px; font-family: verdana">
<h1>Oh gosh!</h1>
<h2>Got error:</h2>
<div style="margin-left: 9px">
<h3>$msg</h3>
</div>
</div>
EOE
}
set_message(\&handle_errors);
}
use strict;
use CGI qw/:standard/;
use Globaldata;
 
To make the DOS window stick around when running the Perl script locally, open it through command prompt.

Start -> Run -> cmd.exe
C:/WINDOWS/System32> cd /
C:/> cd www
C:/www> cd public_html
C:/ cd cgi-bin
C:/ perl myscript.pl

This is long and tedious, so what I usually do to test Perl scripts in DOS is to create a .bat file which basically opens command prompt at its current directory.

i.e. in C:/ I'd have this:
Code:
@echo off
cmd.exe

And then if you open that bat file, it would open command prompt in the same directory as the bat file (so you don't need all the cd commands to get back to the folder your Perl script is in)
 
Thank you all for your responses. I moved the web page and script to another directory and it works. So, the problem appears to be in my Apache server configuration, which I'm looking into now.

I'd still like to know if there is a way to make the DOS window hang around. The method above only works IF you are starting the script in a DOS window, which I am not.

GN
 
You're not opening it in a DOS window, but you want to know how to make the DOS window stick around?

I think on Windows 2000 machines, you could edit the properties of cmd.exe (or command.com) and check a box to make the window stay open when its process has finished. I haven't yet found a way to do this on Windows XP. But this would allow you to simply double-click the Perl file.

If you're looking for a way to have a double-clickable file, you can set up a .bat file specifically for your Perl script (which is what I do for frequently accessed scripts)

Code:
@echo off
perl myscript.pl
pause

The "@echo off" isn't required but it stops the command echoing, i.e. without it you'd see this:

Code:
C:\web\public_html\cgi-bin> perl myscript.pl
[i]the script's output here[/i]
C:\web\public_html\cgi-bin> pause
Press any key to continue . . .
 
cmd.exe -k

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