Re: exit status



Jerry Adair wrote:
Ok I'll keep with my vane of asking potentially obvious questions.

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. Just out of frustration I tried a return() call, and I got the correct return code, albeit with an error message about returning from a non-subroutine.

The code I had was simple enough:

exit(status( <blah blah blah> ));

Maybe one of these will help:

perldoc -f die
perldoc -f exit
perldoc -f eval
perldoc -f system

It sounds like you should be using die or exit, so the issue seems to be
in how the program that's calling the script is detecting the error. It
should look at the exit status, not what's returned on STDOUT.

If you're still stuck, show us how you're calling the script and how you're getting the 'error code'. A simple one liner that calls the script/subroutine that has one line of code (die or exit) should be enough to figure it out.
.



Relevant Pages

  • Re: kill the process
    ... Are you saying you want the program to automatically exit if it's been ... times are more than 3600 seconds apart, exit (see: perldoc -f exit). ... check your Perl program to see if it's been running for an hour, ... all depend on the language in which the hour-long script was written. ...
    (comp.lang.perl.misc)
  • OpenOffice.org 2.0.1 & JDK issue
    ... I know there has been a lot of activity on the mailing lists these days regarding JDK and OOo. ... A part of my script nuked the output after it failed, so I only have the output from script. ... Error code 1, while making 'build_instsetoo_native' ... dell# exit ...
    (freebsd-questions)
  • 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: Problem with Scripted Import When File is Shared, but Not When Its Single-User
    ... script, ... perfectly valid CSV file that is correctly imported when the database ... is in single-user mode returns error code 409 on when it's served from ... Member, FileMaker Business Alliance ...
    (comp.databases.filemaker)