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!

problem with return status from system

Status
Not open for further replies.

gkmccone

Technical User
Oct 24, 2001
17
US
I am trying to make a system call and capture the return
status of the process that completed from the system call.

Problem is that everything is reporting -1 as the return status.

I executed the command line from csh and checked the status
with "echo $status" and it returns 0.

Below is a little test script::

#! /home/gmccone/local/bin/perl
#-d:ptkdb

$e = "sleep 5";
$r = system( $e );
print "Return status: $r $?\n";


Script output::
Return status: -1 -1


So why isn't the return the 0 that I expect and get from
the command line execution??

Thanks for the help

 
The problem, I believe, is that you aren't getting the return status from the system, it's the return status from the function call... system().

To get system OUTPUT you could do this:

$status = 'ps -ef | grep -i csil'

print $status;

To get the status code for a program, you have to be more clever. To clever for me right now since Bernie Mac show is on, and then Titus. So I'll get back to this tommorrow!

--Jim

 
From the perlfunc man page:

The return value is the exit status of the program as returned by the wait() call. To get the actual exit value divide by 256.

Have you tried that? Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Turns out that I left out a "use" line from my posted sample
script. When testing this problem I had a:
"use Schedule::Cron;"
line at the very end of the script. For some reason when I
"use" this Module from CPAN on a solaris system it causes
all return statuses from system(), `` (backticks), and open (|) to have invalid returns.

When I print $! after a system call It returns:
"No child processes"
not sure what this is telling me.

I informed the module developer, so now I sit and wait for
a possible bug fix.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top