Exit status of last command:
Code:
cmd1
ret=$?
return $ret
Or
Code:
tar -zcvf /dev/st0 /home && echo "Backup done" || echo "Backup Failed"
Above will take an action based upon command status:
Quote:
|
But how do get stdout+stderr in a variable?
|
To copy output from both stdout and stderr use
Code:
output=$(cmd1 2>&1)
OR
Code:
output=`command-name 2>&1`
__________________
Vivek Gite
Linux Evangelist

Be proud
RHEL user, and let the world know about your enterprise choices!
Join RedHat user group.

Always use
CODE tags for posting system output and commands!

Do you run a Linux? Let's face it,
you need help