Re: exit status
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 31 Mar 2006 10:11:16 -0800
Jerry Adair wrote:
inside script "1":
my $exitStatus = system( "<call to script #2>" );
print( STDOUT "exit=$exitStatus\n" );
inside script "2": (similar code)
my $return = system( "<call to a program>" );
print( STDOUT "return=$return\n" );
exit( $return >> 8 );
And the output from script "2" gives the number 2, whereas the output from
script "1" gives the number 0.
If the output from script 2 gives you 2, that means that $return is
equal to 2. But then you're shifting 2 to the right 8 bits, and
exiting with that status. That's the status that gets returned to
$exitStatus. You need to be consistant when grabbing these exit
statuses and shifting them.
Here is a series of short-but-complete scripts (as recommended by the
Guidelines - have you read them yet?) that demonstrates how this
works....
$ cat ret2.ksh
#! /bin/ksh
echo "In ret2.ksh"
exit 2;
$ cat call_ret2.pl
#!/usr/bin/perl
use strict;
use warnings;
my $return = system('ret2.ksh');
print STDOUT "return=", ($return >> 8), "\n";
exit ($return >> 8);
$ cat call_call_ret2.pl
#!/usr/bin/perl
use strict;
use warnings;
my $exitStatus = system('call_ret2.pl');
print STDOUT "exit=", ($exitStatus >> 8), "\n";
$ ./call_call_ret2.pl
In ret2.ksh
return=2
exit=2
$
Seems clear to me that exit and shifting both work as they're supposed
to. Now, can you create equally short-but-complete scripts that
demonstrate your error? If so, it's quite likely someone will be able
to help you.
Paul Lalli
.
- References:
- exit status
- From: Jerry Adair
- Re: exit status
- From: Paul Lalli
- Re: exit status
- From: Jerry Adair
- exit status
- Prev by Date: Re: exit status
- Next by Date: Re: Finding the number of occurences in an array
- Previous by thread: Re: exit status
- Next by thread: Re: exit status
- Index(es):
Relevant Pages
|
|