Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Feb 1998 12:11:09 -0800 (PST)
From:      Kwoody <kwoody@citytel.net>
To:        freebsd-questions <freebsd-questions@FreeBSD.ORG>
Subject:   small script question..
Message-ID:  <Pine.BSF.3.91.980203115727.26041A-100000@mybsd.net>

next in thread | raw e-mail | index | archive | help

I'm going away for a week and want to make sure my ppp stays running as I 
have RC5/DES stuff running on a few boxes and this FBSD machine is the 
gateway for them.

I'm using an older version of PPP and every once in a blue moon it dies. 
(upgrade, I know but dont have the time at the moment)

So I want a small script to run oh say every fe hours or something and 
check to see if ppp is up. If not run it.

I wrote this little thing:

#!/bin/sh
ps ax | grep -v grep | grep -q city  
if ( test $? -eq 0 ) 
  then
    echo "found"
else 
   echo "not found"
   echo "running ppp..."
   ppp -auto -alias city
fi

It works as far as I can tell. While testing it I was grepping for the 
word ppp and even if ppp was not running it would return "found".  But as 
soon as I grepped for city instead it works and runs ppp fine.

I use bash and the above if-then-else was from a book on shell 
programming. Is this a "right" way to do this?

thanks,
Keith




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.980203115727.26041A-100000>