[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: exitcodes



*- On  2 Nov, Richard Clarke wrote about "exitcodes"
> I know this is slightly off topic, but could someone tell me how I can
> retrieve the exit code from a unix program and store it into a shell
> variable
>  

In most shells the exit code of the previous command it stored in the
shell variable $?. So depending on your shell you just need to assign
that to another variable for use later.

sh variants

<command>
STATUS=$?

csh variants
<command>
set STATUS=$?


See the man page for the shell you are using.

HTH,
Brian Servis
-- 
------------------------------------------------------------------------
Mechanical Engineering              |  Never criticize anybody until you  
Purdue University                   |  have walked a mile in their shoes,
servis@purdue.edu                   |  because by that time you will be a
http://www.ecn.purdue.edu/~servis   |  mile away and have their shoes.


Reply to: