Active Topics

 


Reply
Thread Tools
JohnLF's Avatar
Posts: 551 | Thanked: 507 times | Joined on Feb 2010 @ North West England
#1
Having problems trying to get a bit of scripting to work on the N900

All I want to do is perform a ping test on a site: -

Code:
#!/bin/sh
if `/bin/ping -c 1 www.google.com`; then
   echo 'Online!'
fi
Unfortunately this simple code does not work and I don't know why. It is saved as pingtest.sh and chmod 755'd. If I run it gainrooted, (" ./pingtest.sh ") I get

Code:
./pingtest.sh: line 4: PING: not found
Running
Code:
ping -c 1 www.google.com
from the command line works just fine.

What am I doing wrong?

Last edited by JohnLF; 2010-03-16 at 17:12. Reason: typo
 
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#2
Originally Posted by JohnLF View Post
What am I doing wrong?
You're using backticks - they return the output of the quoted command, not the return value. Try:
Code:
#!/bin/sh
if (/bin/ping -c 1 www.google.com); then
   echo 'Online!'
fi
 

The Following 3 Users Say Thank You to Rob1n For This Useful Post:
JohnLF's Avatar
Posts: 551 | Thanked: 507 times | Joined on Feb 2010 @ North West England
#3
Doh! That was it, thank you!!
 
Reply


 
Forum Jump


All times are GMT. The time now is 08:57.