How verify that the last instruction was success ?

Hi gusys.

I am developing a script that mount a filesystem ; I would like
verify that this instruction has finished OK !!!

I am tryin to use $? ; but I have doubt How use the if instruction with
the $? variable :

  mount machine:/dir /dir
   if  [ $? == "0" ]
   then
     action 1
   else
     action 2
   fi

Any better choise ?

Thank in Advance

AGAD

There is nothing wrong with what you are doing

mount /IwantAPatekPhillipe /ButIcantAffordOne
 
mount:  you must specify the filesystem type
 
echo $?
32
 
 
mount /IwantAPatekPhillipe /ButIcantAffordOne
 
mount:  you must specify the filesystem type
 
if [ $? -eq 0 ]; then
  echo "Nice one!"
else
  echo "Get a better job."
fi

Get a better job.

Looks like you are mounting a remote directory (actually - you are!). Is that directory on the remote server exported?

I would prefer a numeric comparison. Others may differ.

if [ $? -eq 0 ]
then
            action 1
else
            action 2
fi