Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Aug 2007 14:18:02 -0500
From:      Eric Crist <mnslinky@gmail.com>
To:        Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc:        Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl>, freebsd-questions@freebsd.org, Hinkie <Hinkie@paradise.net.nz>
Subject:   Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig em0 up)
Message-ID:  <14ECFF9B-9559-4B45-B44B-8E030597B00C@gmail.com>
In-Reply-To: <20070829185450.GA15895@kobe.laptop>
References:  <01a901c7ea3d$0ad62720$1e00a8c0@cheqsoft.local> <20070829185012.A14865@wojtek.tensor.gdynia.pl> <20070829185450.GA15895@kobe.laptop>

next in thread | previous in thread | raw e-mail | index | archive | help
On Aug 29, 2007, at 1:54 PMAug 29, 2007, Giorgos Keramidas wrote:

> On 2007-08-29 18:51, Wojciech Puchar  
> <wojtek@wojtek.tensor.gdynia.pl> wrote:
>> fragment from my test program (used for other thing but doesn't  
>> matter)
>>
>> /sbin/ping -i 0.5 -s 1450 -c 3 tested_host >/dev/null 2>/dev/null
>> if [ $? != 0 ];then
>>   perform_action_if_doesnt_ping
>> fi
>
> I'm not sure if '!=' is a 'portable' way to write sh(1) tests,
> but you have a point there :-)
>
> Rewriting this as:
>
>         #!/bin/sh
>
>         ping -i 0.5 -s 1450 -c 3 tested_host >/dev/null 2>&1
>         if test $? -eq 0 ; then
>                 exit 0
>         fi
>
>         perform_action_if_doesnt_ping
>
> may save you an extra indentation level too.

AFAIK, the != is evaluated by test, not sh.
-----
Eric F Crist
Secure Computing Networks





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14ECFF9B-9559-4B45-B44B-8E030597B00C>