[KLUG Members] getting exit code in bash script

Bruce Smith bruce at armintl.com
Fri Mar 11 11:41:33 EST 2005


#!/bin/sh
somecommand
exitcode=$?
if [ $exitcode -eq 0 ]
   then
      echo "Everything is O.K."
   else 
      echo the exit code for somecommand was: $exitcode
fi

> How can I get the exit code in a bash script?
> 
> I'm using 
> 
>     if [ $? -eq 0 ]
>       then
>       echo "Everything is O.K."
>     else 
> 
>       # want to get exit code here
>     fi




More information about the Members mailing list