[Gloucs] What's wrong with this code?

Glyn Davies glynd at walmore.com
Mon Jul 30 23:08:07 BST 2007


Keith Edmunds wrote:
> 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
>   
He he. As I said, mine is a rubbish way of testing (I'm no programmer). 
Your's certainly looks better. However, I think it still has a flaw. :)


-- 
Best Regards
Glyn Davies



More information about the gloucs mailing list