executing multiple perl programs sequentially and checking return values for errors

Discussion in 'Perl Misc' started by brad, Jan 15, 2004.

  1. brad

    brad Guest

    I have written 10 or so perl programs that do testing on cell phones.
    I am new to perl, and I need to know how to execute these programs one
    after the other, and check return values. The program returns 1 if
    the phone crashes. Even if a program returns a non zero result, I want
    to be able to print the error and move on to the next test case.
    Please help!
    Thanks Brad
     
    brad, Jan 15, 2004
    #1
    1. Advertising

  2. In article <>,
    brad <> wrote:
    :I have written 10 or so perl programs that do testing on cell phones.
    :I am new to perl, and I need to know how to execute these programs one
    :after the other, and check return values. The program returns 1 if
    :the phone crashes. Even if a program returns a non zero result, I want
    :to be able to print the error and move on to the next test case.

    Sounds like a job for the Test:: family of modules. Pretty much
    every CPAN module self-tests using Test, so there are lots
    of examples to choose from.
    --
    "Mathematics? I speak it like a native." -- Spike Milligan
     
    Walter Roberson, Jan 15, 2004
    #2
    1. Advertising

  3. brad

    Ben Morrow Guest

    (brad) wrote:
    > I have written 10 or so perl programs that do testing on cell phones.
    > I am new to perl, and I need to know how to execute these programs one
    > after the other, and check return values. The program returns 1 if
    > the phone crashes. Even if a program returns a non zero result, I want
    > to be able to print the error and move on to the next test case.


    (untested)

    #!/usr/bin/perl -l

    my @tests = qw/1.pl 2.pl/; # or whatever
    system $^X, $_ and print "$_ failed: $?" for @tests;

    Ben

    --
    "The Earth is degenerating these days. Bribery and corruption abound.
    Children no longer mind their parents, every man wants to write a book,
    and it is evident that the end of the world is fast approaching."
    -Assyrian stone tablet, c.2800 BC
     
    Ben Morrow, Jan 15, 2004
    #3
  4. brad

    pkent Guest

    In article <>,
    (brad) wrote:

    > I have written 10 or so perl programs that do testing on cell phones.
    > I am new to perl, and I need to know how to execute these programs one
    > after the other, and check return values. The program returns 1 if
    > the phone crashes. Even if a program returns a non zero result, I want
    > to be able to print the error and move on to the next test case.


    The perl program's exit code can be set with exit(). Exactly what your
    OS _does_ with that value is system dependent. In a bourne shell script
    under Unix you can access the last program's exit status with the $?
    variable. So you could use your bourne shell programming skills to run
    one perl program, check its return val, optionally do something, run the
    next one...

    OTOH if you're on VMS my recollection of, er, the batch command
    interpreter is hazy.

    P

    --
    pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
    Remove the tea to reply
     
    pkent, Jan 15, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. brad
    Replies:
    2
    Views:
    3,982
    Joe Smith
    Jan 19, 2004
  2. Johan Tibell
    Replies:
    66
    Views:
    1,064
    Chris Torek
    Aug 7, 2006
  3. ZelluX
    Replies:
    15
    Views:
    843
    Arne Vajhøj
    Jun 25, 2008
  4. Casey Hawthorne
    Replies:
    14
    Views:
    464
  5. NickName

    Loading multiple pages sequentially?

    NickName, Sep 20, 2006, in forum: Javascript
    Replies:
    0
    Views:
    80
    NickName
    Sep 20, 2006
Loading...

Share This Page