perldoc -f qx
Um, the OP was asking about capturing the exit status of a C program, which involves using the "system()" call (perldoc -f system) -- not "qx" (aka the backtick operator), which just captures the program's stdout. Also -- OOPS, sorry. I should have read the docs more carefully myself, to see that qx returns stdout and sets $? -- thanks, I'm glad I finally learned that.
Anyway (end of update), the more direct reference for qx is "perldoc perlop" (which is where "perldoc -f qx" tells you to look).
Another reply below points to the usage of "system()", along with the "$?" variable -- though I prefer using a scalar that has a meaningful name, e.g.:
(closing remark to updates: my old habit of using "system()" to get the exit status, vs. using backticks to get stdout data, was simply a matter of being unaware of the $? variable, which is set in either case.)my $exit_stat = system( "some_shell_command ..." ); printf "Shell_command exit status was %d\n", $exit_stat/256; print "(which means it probably failed)\n" if $exit_stat != 0;
In reply to Re: Re: getting the return value from a C program
by graff
in thread getting the return value from a C program
by podian
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |