SYSTEM command problem

D

dcs_thebob

I have a Win2003 server running as a webserver. This box crashed
recently and I had to load all my .pl scripts from a backup. Now, I
have the site up and running, but one of my scripts isn't functioning
the way I need.

Basically, the script does its thing by creating a temp file, then uses
a simple dos based smtp mailer to send the file out via email (blat).
I can run the script from the website and it creates the file fine.
But the last line of code runs a SYSTEM command that calls Blat.exe and
emails the file, doesn't execute.

I can run Blat from the command line, with the same options and it
works fine. I even hard coded my email address and the same switches
in the System command in the script and it didn't work. I have given
the EVERYONE group full rights to the blat.exe file and folder. I'm
down to this one issue and this server is up and going. Any ideas will
be appreciated.

tb
 
S

Sherm Pendley

Basically, the script does its thing by creating a temp file, then uses
a simple dos based smtp mailer to send the file out via email (blat).
I can run the script from the website and it creates the file fine.
But the last line of code runs a SYSTEM command that calls Blat.exe and
emails the file, doesn't execute.

Perl will tell you what's wrong - if you ask it to.

system('foo -b -a -r') != -1
or die "Could not run foo. Reason: $!";

For that matter, there may already be messages from blat.exe in your error
log, if perl is able to launch it, but it's failing for some reason. The
child process launched by system() inherits perl's stdin and stdout.

Another place to look for clues would be blat.exe's error log, if it has
one.

sherm--
 
D

dcs_thebob

Thanks for the info. I'm a complete Perl noob, so this will come in
handy. In my current setup the script is ran from a website, so where
would the Reason code and all be displayed/output to? It doesn't show
up on the website (obviously), so does perl have a "normal" log file
that would receive this kind of message?

thanks again, sorry for the basic questions.

tb
 
S

Sherm Pendley

Thanks for the info.

You can thank me by doing everyone here a favor: Quote the messages you
are replying to, like the rest of us do. Thanks.
In my current setup the script is ran from a website, so where
would the Reason code and all be displayed/output to?

Your web server's error log.

Or, you can use the CGI::Carp module to have the error messages sent to
the browser instead:

use CGI::Carp qw(fatalsToBrowser);
up on the website (obviously), so does perl have a "normal" log file
that would receive this kind of message?

The child process started with system() inherits stdin, stdout, and stderr
from Perl. Web servers generally route the stderr from a CGI to the web
server's error log.

Although, I don't know what web server you're using, so I can't swear that
it's doing that.

sherm--
 
J

John W. Krahn

Sherm said:
Perl will tell you what's wrong - if you ask it to.

system('foo -b -a -r') != -1
or die "Could not run foo. Reason: $!";

perldoc -f system
[snip]
@args = ("command", "arg1", "arg2");
system(@args) == 0
or die "system @args failed: $?"


You will probably get a better error message if you use $? instead of $!.


John
 
S

Sherm Pendley

John W. Krahn said:
Sherm said:
Perl will tell you what's wrong - if you ask it to.

system('foo -b -a -r') != -1
or die "Could not run foo. Reason: $!";

perldoc -f system
[snip]
@args = ("command", "arg1", "arg2");
system(@args) == 0
or die "system @args failed: $?"


You will probably get a better error message if you use $? instead of $!.

Mea culpa - I *did* perldoc -f system, but didn't read far enough down. A
couple of paragraphs above the above example, there's this:

Return value of -1 indicates a failure to start the program (inspect
$! for the reason).

sherm--
 
T

Tad McClellan

I'm a complete Perl noob,


That is irrelevant, since your question is not about your
choice of programming language.

In my current setup the script is ran from a website, so where
would the Reason code and all be displayed/output to? It doesn't show
up on the website (obviously), so does perl have a "normal" log file
that would receive this kind of message?


Where your web server puts messages has no relationship to what
programming language you have chosen to write your CGI program.

If you wrote it in Python, the program's output would go to the
same place(s) as if you wrote it in Perl or Visual Basic.

You don't have a programming language question.

You have a web server configuration question.

Ask web server configuration questions in a newsgroup that has
some connnection with WWW stuff, such as:

comp.infosystems.www.servers.mac
comp.infosystems.www.servers.misc
comp.infosystems.www.servers.ms-windows
comp.infosystems.www.servers.unix
 
B

Ben Morrow

Quoth Sherm Pendley said:
John W. Krahn said:
Sherm said:
Perl will tell you what's wrong - if you ask it to.

system('foo -b -a -r') != -1
or die "Could not run foo. Reason: $!";

perldoc -f system
[snip]
@args = ("command", "arg1", "arg2");
system(@args) == 0
or die "system @args failed: $?"


You will probably get a better error message if you use $? instead of $!.

Mea culpa - I *did* perldoc -f system, but didn't read far enough down. A
couple of paragraphs above the above example, there's this:

Return value of -1 indicates a failure to start the program (inspect
$! for the reason).

In general you need to inspect all of $?, $!, and, on Win32, $^E to find
out what went wrong. If the fork or exec (or spawn, as appropriate)
failed, the error is in $! and/or $^E. If the program started correctly,
but exitted with an error status, that will be in $?.

Go read perlvar again :)

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top