[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: tail -f termination, after ppp established.



Marvin Stodolsky wrote:
> 
> Please respond to Stodolsk@erols.com as well as the List.
> The script below is user to establish dial-in.
> 
> #!/bin/sh
> # connect to IP through Lucent WinModem
> echo "  "
> echo Inserting Winmodem Lucent Tech  ltmodem.o  driver
> /sbin/insmod -f ltmodem
> pon $1
> tail -f /var/log/syslog
> --------------------------
> 
> The syslog report confirming the login is, for example:
> 
> Jul 20 11:56:44 koala pppd[526]: local  IP address 207.172.166.1
> Jul 20 11:56:44 koala pppd[526]: remote IP address 10.65.101.11
> Jul 20 11:56:44 koala pppd[526]: Script /etc/ppp/ip-up started (pid 531)
> Jul 20 11:56:44 koala pppd[526]: rcvd [CCP ConfRej id=0x2]
> Jul 20 11:56:45 koala pppd[526]: Script /etc/ppp/ip-up finished (pid
> 531),
>  status = 0x0
> 
> The question is, how could
>   Script /etc/ppp/ip-up finished (pid 531),  status = 0x0
> be used to automatically terminate
>    tail -f /var/log/syslog
> reporting to console.

You could put the 'tail -f' in the background, storing its PID in a
variable, then do a timed loop on the syslog file, looking for the line
'pppd[.*ip-up finished', then issue a kill to the saved pid:

### Add to your existing script

tail -f /var/log/syslog &
tailPID=$!

until grep -q 'pppd[.*ip-up finished' /var/log/syslog
do
    sleep 10 # select a delay that works for you
done

kill $tailPID

###

There are surely other, perhaps simpler ways, but this should work
(though not tested, YMMV).

-- 
Bob McGowan
Staff Software Quality Engineer
VERITAS Software
rmcgowan@veritas.com



Reply to: