Link to home
Start Free TrialLog in
Avatar of weinerk
weinerk

asked on

perl & errorlevel

is there a way to import back into perl  
dos errorlevel after executing
system(<some DOS command>);
from a perl program
Avatar of mgjv
mgjv

> perldoc -f system

=item system LIST

Does exactly the same thing as "exec LIST" except that a fork is done first, and the parent process waits for the child process to complete. Note that argument processing varies depending on the number of arguments. 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 L</exec>. This is I<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 L<perlop/"`STRING`">.

I suspect that it works the same on all platforms, meaning that the DOS error level should be returned, multiplied by 256

I think mgjv is on the right track.  In UNIX I would just try something like...

$ouput = system("some","command");

Then the output from some command is returned and stored in $output.  Try this on your PC.  Good luck.
ASKER CERTIFIED SOLUTION
Avatar of dmethvin
dmethvin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
If the problem is that the shell isn't passing back the exit status,
might you be able to bypass COMMAND.COM the same way you can bypass /bin/sh by calling
          $ouput = system('command', $arg1, $arg2);
instead of
          $ouput = system("command $arg1 $arg2");
?