[Gloucs] What's wrong with this code?

Glyn Davies glynd at walmore.com
Mon Jul 30 23:13:26 BST 2007


Nick wrote:
> On Mon, Jul 30, 2007 at 10:33:27PM +0100, Glyn Davies wrote:
>   
>> No prizes for getting the answer right as I've found it and feel free to 
>> spot the problem immediately and make me look a fool.
>>
>> 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 it'd be slightly nicer to use something like:
>
> if [ -n "$(ping -c 1 192.168.1.200 | grep '1 received')" ]
>
> which would use test's inbuilt "is string zero" function.
>
>   
When I hack, I hack dirty :)
> I'm not sure why it isn't working, though. Not in the mood for
> debugging bash (still counts as debugging, right? even if only one
> line? yeah ;))
>
> Hi GlosLUG, btw. I live in Winchcombe, but attend university far
> away. Back for the summer though, so will try to attend a few meets
> before it's through. Weather permitting, of course ;)
>
> -Nick
>   
Look forward to meeting you. The next meeting should be on the 21st 
August. I'll announce it on this list in due course.

-- 
Best Regards
Glyn Davies



More information about the gloucs mailing list