Gabor Urban wrote:
Hi,

I think the question at hand may be quite simple, though I could not
figure the asnwer out :-))

MyScript.pl runs an other script (foo.pl) with the system call:

system foo.pl arg1 arg2 ;

I would like to have a status report (error flag) from foo.pl, which
does some exit's and die's at error occurences. How can I catch these
in MyScript.pl? What does die deliver as error code?

REgards,

Gabaux

If your error conditions are going to be simple enough you may consider catching the output of the program
like
pipeopen or backticks
$OUTPUT=`foo.pl args... 2>&1` ; This wont work on Micro$oft systems


else
Instead in your main program call
do "foo.pl args..."

And in foo.pl set some scope defined variable like

#foo.pl
$dbh=connect(....)
unless($dbh){
  $GLOBAL::ERRORSTR="Couldnot connect to database $@";
   exit 1
}


And in the main program you can check


if($GLOBAL::ERRORSTR) {
  # Hmm something went wrong
...........

}


But personally I consider this as dirty work though it works. Let me know If you get a better way


Ram




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



Reply via email to