I’m using Perl 5.10.1 on Ubuntu 11.04. I want Perl to execute a shell script and exit with the same code the shell script exits. But this isn’t working for me …
system($runCmd) or die("Failed to run \"$runCmd\": $!");
I have confirmed that running the “$runCmd” by itself returns an exit code of 255, but the “die” clause isn’t getting invoked. How do I exit with the correct code or at least fail for non-success codes?
Another minor requirement is that I want the output from $runCmd to be printed to the screen.
As
perldoc -f diesays,diedoesn’t give a specific exit code (only a nonzero exit code). To get what you want, you’ll need something like: