> 
> 
> Is there a way to have a perl script exit with a status code?
> 
> For instance I have ascript that calls another script via
> system("somescript"); 
> 
> I want to then be able to get the exit status of that script.
> 
> Paul

Have you seen the perldoc for system ?
----
<snip>
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.
See also the exec entry elsewhere in this document. This is
*not* what you want to use to capture the output from a command,
for that you should use merely backticks or "qx//", as described
in the section on "`STRING`" in the perlop manpage. Return value
of -1 indicates a failure to start the program (inspect $! for
the reason).

Like "exec", "system" allows you to lie to a program about its
name if you use the "system PROGRAM LIST" syntax. Again, see the
exec entry elsewhere in this document.

Because "system" and backticks block "SIGINT" and "SIGQUIT",
killing the program they're running doesn't actually interrupt
your program.

    @args = ("command", "arg1", "arg2");
    system(@args) == 0
         or die "system @args failed: $?"

You can check all the failure possibilities by inspecting "$?"
like this:

    $exit_value  = $? >> 8;
    $signal_num  = $? & 127;
    $dumped_core = $? & 128;

When the arguments get executed via the system shell, results
and return codes will be subject to its quirks and capabilities.
See the section on "`STRING`" in the perlop manpage and the exec
entry elsewhere in this document for details. 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to