Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig em0 up)

[ Available lists | Index of freebsd-questions | Month of Aug 2007 | Week of 29 Aug 2007 | Raw email | View thread | Wrap long lines | Reply | Tag ]
From
Giorgos Keramidas <keramida@ceid.upatras.gr>
Date
29 Aug 2007 18:55:53
Subject
Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig em0 up)
Message-ID
20070829185450.GA15895@kobe.laptop

In reply to
References to
Replies

[ Hide this part ]
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.



Elapsed time: 0.110 seconds