[Gloucs] What's wrong with this code?

Keith Edmunds kae at midnighthax.com
Mon Jul 30 23:02:48 BST 2007


On Mon, 30 Jul 2007 22:33:27 +0100, glynd at walmore.com said:

> What's wrong with this line of code. Okay, other than it being a rubbish 
> way of testing that your gateway is available?
> 
> if [ "$(ping -c 1 192.168.1.200 | grep '1 received')" != "" ]

Well, you could make it a lot shorter:

if ping -c 1 192.168.1.200 >/dev/null
then
	echo "gateway reachable"
else
	echo "gateway unreachable"
fi

Maybe you had other errors in mind?

Keith

-- 
Keith Edmunds

+---------------------------------------------------------------------+
|  Tiger Computing Ltd  |  Helping businesses make the most of Linux  |
|  "The Linux Company"  |       http://www.tiger-computing.co.uk      |
+---------------------------------------------------------------------+



More information about the gloucs mailing list