1. if you want to evaluate pidof pppd and store the result, you need backticks (backquotes) not regular single quotes
or in bash you can use
2. as well as quotes around the variables, you need space around the [ and ] i.e.
Code:
if [ "$x" != "\n" ]
3. a better way to test for an empty return value might be to use the -z (zero length string) or -n (non-zero length string) tests e.g.
Code:
$ x=`pidof pppd`
$ if [ -z "$x" ]; then echo "empty"; else echo "not empty"; fi
empty
$
$ x=`pidof firefox`
$ if [ -z "$x" ]; then echo "empty"; else echo "not empty"; fi
not empty
or
Code:
$ x=`pidof pppd`
$ if [ -n "$x" ]; then echo "not empty"; else echo "empty"; fi
empty
$
$ x=`pidof firefox`
$ if [ -n "$x" ]; then echo "not empty"; else echo "empty"; fi
not empty
Bookmarks