# SYNHOST=caalt04 # ping -c 1 $SYNHOST ping: unknown host caalt04 # if [ $? -eq 0 ] ; then > echo "Synergy connected" > > else > > echo "Synergy NOT connected" > > fi
Synergy NOT connected cut and pasted. Works fine, although you probably need to expand SYNHOST to a fqdn I'm using # echo $SHELL /bin/bash Are you??? If not, add the line #!/bin/bash ( or wherever it is ) to the top of the script and see if this improves things. Steve On Thu, 17 Apr 2008 12:16:17 +1200 Kerry Mayes <[EMAIL PROTECTED]> wrote: > Thanks Rex, yes that's a much better way of doing it. > > Still having difficulty though - I think its either with quotes or > semi-colons now... > > As I understand it, ";" are required between statements that are in > places where only one statement is expected. So, keeping it to it's > simplest form: > > SYNHOST=caalt04 > ping -c 1 $SYNHOST > if [ $? -eq 0 ] ; then > echo "Synergy connected" > > else > > echo "Synergy NOT connected" > > fi > > Returns: > > PING caalt04.caa.local (192.168.0.183) 56(84) bytes of data. > 64 bytes from caalt04.caa.local (192.168.0.183): icmp_seq=1 ttl=64 time=0.172 > ms > > --- caalt04.caa.local ping statistics --- > 1 packets transmitted, 1 received, 0% packet loss, time 0ms > rtt min/avg/max/mdev = 0.172/0.172/0.172/0.000 ms > Synergy connected > : not founddefault: 11: else > Synergy NOT connected > > So the ping command works but the if statement doesn't - the else > isn't recognised so it's doing both commands.
pgpKp1lXd8aNw.pgp
Description: PGP signature
