Professional Web Applications Themes

Script Exit Status - Perl / CGI

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...

  1. #1

    Default Script Exit Status

    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

    Paul Kraus Guest

  2. #2

    Default RE: Script Exit Status

    >
    >
    > 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 doent. 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 doent.

    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 doent for details.

    James Kipp Guest

  3. #3

    Default RE: Script Exit Status


    Perldoc -f exit



    -----Original Message-----
    From: Paul Kraus [mailtokrauspelsupply.com]
    Sent: Tuesday, December 02, 2003 9:32 AM
    To: [email]beginnersperl.org[/email]
    Subject: Script Exit Status

    Is there a way to have a perl script exit with a status code?

    Tim Johnson Guest

Similar Threads

  1. Net::telnet - need to retrieve the exit status
    By Anita in forum PERL Modules
    Replies: 1
    Last Post: September 2nd, 05:13 AM
  2. ksh script, exit status and pipe
    By Ian Wilson in forum Linux / Unix Administration
    Replies: 1
    Last Post: August 25th, 12:49 PM
  3. exit perl script and cd in bash?
    By Kenton Brede in forum PERL Beginners
    Replies: 5
    Last Post: January 21st, 03:58 AM
  4. DBI: exit status, sql operation
    By Christian Eriksson in forum PERL Modules
    Replies: 1
    Last Post: November 29th, 06:15 PM
  5. window exit script
    By Rose Roland in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 12th, 09:24 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139