Hi,
The exit status of a program is held in the following variable:
$?
If the content of that variable is 0 (zero) it means all is OK. If it is anything else than that something is "wrong" (if it is actually wrong depends on the program and the number given, you need to check the manpage of that program to see what the number means).
Try this:
Quote:
$ ls -l /etc/fstab
-rw-r--r-- 1 root root 2799 Jan 25 16:23 /etc/fstab
$ echo $?
0
$ ls -l /etc/dummy
ls: /etc/dummy: No such file or directory
$ echo $?
2
|
About your example:
Code:
#!/bin/bash
this="that"
#this="perl"
whatis $this 1>/dev/null 2>&1
ExitStatus="$?"
if [ $ExitStatus == "0" ]; then
echo "I know what $this is"
else
echo "I don't know what $this is"
fi
Hope this helps.