Hi,
I'm trying to write a very simple shellscript, but somehow it does exactly the opposite of what I expected.
I want to run a script, but only if a particular server in my network is reachable.. So here's my script:
(note that the IP address does not exist in my network...)
-------------------------------------------------------------------------
#!/bin/bash
pingresult=( `ping -w 3 192.168.1.100 |grep -i unreachable` )
if [ -z $pingresult ]
then
echo "Network-machine is not reachable"
else
echo "Yup, the machine replied"
fi
----------------------------------------------------------------------------
I thought that the test -z checked for an empty string.
So, if $pingresult is empty, the test -z should return true, thus it should echo Network-machine not reachable.
However, it echos the Yup ... thing
When I use an existing IP address, it echo's the: Network-machine not reachable..
Shouldn't it be the other way around? Am I missing something here, or did I do something wrong???
(Or if anyone knows a better way to see if a machine can be reached through the network, please feel free to share it with me

)