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

Re: Waiting for scripts in /etc/ppp/ip-up.d



On Wed, 21 Oct 1998,  Raymond A. Ingles wrote:

> On Wed, 21 Oct 1998, Moore, Paul wrote:
> > What I'd like to do is to write a script which starts the PPP
> > connection, then waits for all the ip-up.d scripts to run, and for my
> > mail to finish arriving, and then drops the connection with poff
> > (actually, I'd like it to ask me whether it was OK to go offline, and
> > allow me to override, but that's not too hard).
> 
>  Well, could you add a script in ip-up.d that runs last, and checks to see
> if mail is finished? This might solve part of your problem...

it would be best to call your script after ip-up, from the script calling
ip-up.
that could be something like:

#!/usr/local/bin/perl
#we'll call this script ppp-wrapup.pl

#lets user set timeout value on the command line (ie, 
#ppp-wrapup.pl <timeoutvalue>)
($ARGV[0] =~ /^\d*$/)? ($timeout = $ARGV[0]): ($timeout = 5);

#wait for ip-ups to die  ... maybe you don't really want to do that.
while(grep /ip\-up\.d/, `ps -aef`){ 
	last if($a++ > $timeout); 
	sleep 5; 
}

#keep track if ip-up finished
$done++ unless ($a > 4);

#wait for mail script to finish
sleep 5;
while(grep /<mailprogram>/, `ps -aef`){ 
	last if($b++ > $timeout); 
	sleep 5;
}

#again keep track
$done++ unless ($b > 4);

if($done > 0){
#do your work killing the connection here

}else{
#handle the timeout here

}

exit;

--
quiet rob
-----------
"Just keep telling yourself you are immortal"  --Albert Hofmann




Reply to: