executing multiple perl programs sequentially and checking return values for errors

B

brad

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
 
W

Walter Roberson

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

Ben Morrow

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
 
P

pkent

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top