[Gloucs] What's wrong with this code?
Nick
gloslug at njw.me.uk
Mon Jul 30 23:06:07 BST 2007
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.
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
--
GPG Key : www.njw.me.uk/nick.gpg.asc GPG Key ID: 04E4653F
GPG Fingerprint: 9732 D7C7 A441 D79E FDF0 94F6 1F48 5674 04E4 653F
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mailman.lug.org.uk/pipermail/gloucs/attachments/20070730/1eedeeef/attachment.bin
More information about the gloucs
mailing list