Re: exit status



Paul-

Not sure why I am getting the flack from you, but whatever. The question
seemed simple enough to me, I never said that exit() was broken. Sheesh.

Anyway, I have read the documentation and know about the return value from
wait, etc. To answer the other questions I have been asked, I am using
system() calls to invoke the script.

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. From doing more reading in the Camel (yes, I
have already read all of the function descriptions that the other poster
suggested, I did try to solve this one on my own before coming here, believe
it or not) exit() doesn't actually exit straight away, but it calls some END
routines (I don't have any of those defined) which might change $? - perhaps
that is part of the problem.

Curiously, I changed the system() call in script "2" to an exec() call, and
I get the correct return value in script "1", namely the number 2.

I hope this helps. Any more flack and I think I'll punt and seek help
elsewhere.

Thanks,

Jerry

"Paul Lalli" <mritty@xxxxxxxxx> wrote in message
news:1143823805.677400.254100@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Jerry Adair wrote:
Ok I'll keep with my vane of asking potentially obvious questions.

Your problem is not with the obviousness of the question, but of the
complete lack of necessary information provided.

I am attempting to return an error code from a Perl script. At first
blush,
it seemed easy with the exit() call. But it doesn't work.

Yes it does. Come on. Do you really think that exit() is somehow
broken in the language, and you're just the first person to ever
notice?

Perhaps you could tell us exactly *how* you're determining that it
"doesn't work"?

Have you read the posting guidelines for this group yet? They contain
excellent advice and information on how to get the most help possible
from this group.

Paul Lalli



.



Relevant Pages

  • Re: Changing a users password non-interactively?
    ... You need expect and a setpass.expect script which ill add ... exit with a nasty warning. ... # Be careful of the COMMAND and UNDOCMD - they are dependant on your ...
    (comp.unix.aix)
  • Re: script does not always work the same each time.
    ... I have written a simple script to test code build and test run on a ... $lineterminationChar {append output $expect_out; ... exit 1;} ...
    (comp.lang.tcl)
  • Re: need small PHP job done
    ... i need help tweaking a PHP mail script; ... // check for a recipient email address and check the validity of it ... // check for an attachment if there is a file upload it ...
    (alt.php)
  • Re: OSR505 Signal trapping in shell scripts
    ... >>My test script is at the end. ... > process only gets one SIGHUP per fd. ... > end up doing ioctls on fd 0, which is your stopio'd telnetd pty. ... > of the exit function. ...
    (comp.unix.sco.misc)
  • Re: Changing a users password non-interactively?
    ... You need expect and a setpass.expect script which ill add ... exit with a nasty warning. ... # Be careful of the COMMAND and UNDOCMD - they are dependant on your ...
    (comp.unix.aix)