3/20 How do you get the error code of a system program in bash (or perl)?
If I have in my_error.c int main (...) { exit (234); }
how do I get that 234 in a variable? In bash,
ec=my_error // sets $ec to the string "my_error"
ec=`my_error` // sets $ec to the stdoutput of my_error
and I get similar results in perl. What am I doing wrong?
\_ $ ./my_error
$ echo $?
\_ In perl, assuming the "hello_world" program merely prints
the text "hello, world!":
$foo = `./hello_world`; ## $foo now has "hello, world!"
$exit_val = ($? >> 8); ## $? contains the exit status as well
## as exciting flags in the low
## bits; perldoc perlvar for more.
-geordan |