IMHO, the suggestions put forward thus far, whilst returning the status code back to the calling script, don't appear to address leonidlm's interest in the output from the called batch script - so why not just use backticks. That way, you gain access to the return code (via $?) and the output (via the return from the backtick invocation) e.g.
my $output = `batch_file args`;
die "Gone horribly wrong - $?" if $?;
# or ...
my @output = `batch_file args`;
die "Gone horribly wrong - $?" if $?;
.oO(Unless, of course, Windoze sees fit to not return the status code from the batch script, in which case...)
my $output = `batch_file args && exit /b ERRORLEVEL`;
die "Gone horribly wrong - $?" if $?;
# or ...
my @output = `batch_file args && exit /b ERRORLEVEL`;
die "Gone horribly wrong - $?" if $?;
,or something similar, may suffice ... unless I'm missing something obvious?!
Sits back and awaits flames, errm, constructive observations ;-)
HTH ,
At last, a user level that overstates my experience :-))
|