View Single Post
gobuki's Avatar
Posts: 60 | Thanked: 46 times | Joined on Jan 2010 @ Europe
#20
Originally Posted by eitama View Post
Thank you very much CowboyFromHell,

The example you posted works well, but when I tried to adapt it a bit to my needs, I have an odd error :

Code:
Nokia-N900-02-8:/etc/network# vi detectUsb.sh
#!/bin/sh

my=`/sbin/ifconfig`

if [ `echo $my | grep RUNNING` ]
then
        echo "Ok"
else
        echo "Not ok"
fi

Nokia-N900-02-8:/etc/network# ./detectUsb.sh
sh: Link: unknown operand
Not ok
Could you help me out on this one?
I am a big bash / sh noob.

I think the error you made is you are testing the output of grep and not its return value that is in $? after grepping.

Last edited by gobuki; 2010-03-11 at 18:05. Reason: typo