Reply
Thread Tools
eitama's Avatar
Posts: 702 | Thanked: 334 times | Joined on Feb 2010 @ Israel.
#1
I've been at this for 3 hours now.
It's not wrorking.

Code:
#!/bin/sh

#my=`/sbin/ifconfig usb0`
my="abcd"

if [ $my == "*bc*" ]
then
        echo "Ok"
else
        echo "Not ok"
fi
This prints "Not ok" when i would expect it to print Ok.

I ran this on my phone using putty.

On the other hand :

this works :

Code:
#!/bin/sh

#my=`/sbin/ifconfig usb0`
my="abcd"

if [ $my == "abcd" ]
then
        echo "Ok"
else
        echo "Not ok"
fi
Please help
 
gobuki's Avatar
Posts: 60 | Thanked: 46 times | Joined on Jan 2010 @ Europe
#2
I didn't know that * is working like that with strings. Is it? It's expanded to filesystem objects names in bash.

If you are sure this should work. How about using #!/bin/bash? :-)
 
eitama's Avatar
Posts: 702 | Thanked: 334 times | Joined on Feb 2010 @ Israel.
#3
As far as I know, glob works with == yes,

But, there is no bash on the N900, busybox....
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#4
Code:
#!/bin/sh

#my=`/sbin/ifconfig usb0`
my="abcd"

if [ "$my" == *bc* ]
then
        echo "Ok"
else
        echo "Not ok"
fi
Maybe?
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 
eitama's Avatar
Posts: 702 | Thanked: 334 times | Joined on Feb 2010 @ Israel.
#5
Originally Posted by fatalsaint View Post
Code:
#!/bin/sh

#my=`/sbin/ifconfig usb0`
my="abcd"

if [ "$my" == *bc* ]
then
        echo "Ok"
else
        echo "Not ok"
fi
Maybe?
Doesn't matter, still won't work.
The thing that is not working is the * (asterisks).

What I am ultimately trying to do is check if usb0 is RUNNING.
 
JosefA's Avatar
Posts: 71 | Thanked: 54 times | Joined on Oct 2009
#6
PHP Code:
#!/bin/bash

my="abcd"

if [[ $my = *bc* ]]
then
        
echo "Ok"
else
        echo 
"Not ok"
fi 
__________________
$HOME - On special days, this sig will contain a hidden Andalusian Video Snail. Today is not such a day.
 
eitama's Avatar
Posts: 702 | Thanked: 334 times | Joined on Feb 2010 @ Israel.
#7
Originally Posted by JosefA View Post
PHP Code:
#!/bin/bash

my="abcd"

if [[ $my = *bc* ]]
then
        
echo "Ok"
else
        echo 
"Not ok"
fi 
I don't have BASH on my N900.
 
Posts: 38 | Thanked: 17 times | Joined on Oct 2009 @ Missouri
#8
Comparing strings like this is a form of regex which requires you use double square brackets around it: if [[ ]]
 

The Following 2 Users Say Thank You to kopele For This Useful Post:
JosefA's Avatar
Posts: 71 | Thanked: 54 times | Joined on Oct 2009
#9
The point is, look at the difference between that and your code. The point isn't "do you have bash on your N900". I don't either.
__________________
$HOME - On special days, this sig will contain a hidden Andalusian Video Snail. Today is not such a day.
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#10
Oops.. I forgot the double brackets.

I knew the lack of quotes on the *bc* though...
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 

The Following User Says Thank You to fatalsaint For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 21:19.