Date: Tue, 09 Jun 1998 08:31:59 -0300 From: Capriotti <capriotti@geocities.com> To: freebsd-questions@FreeBSD.ORG Subject: Perl to sh script Message-ID: <3.0.32.19691231210000.00a4ae50@pop.mpc.com.br>
next in thread | raw e-mail | index | archive | help
Hello.
I'm trying to write the following script (with no success, of course):
Script name: internet
Accepted parameters: ON or OFF
if call is internet on or internet ON :
check if ppp -alias -auto isp is running
if not, call ppp -alias -auto isp
if call is internet off or internet OFF:
check if ppp -alias -auto ips is running
get PID
kill process
exit
I've found something that might help me in the list archives, but it seems
to be in perl and I, for several reasons, wouldn't like to install perl
support, so I'm attempting to make something similar in a sh script.
Could someone help me AND point a (or some) good link to learn shell
programing ?
******* script found: *************
#!/usr/bin/perl
$PPPcommand="ppp -alias -auto mpc"
open(InPipe, " ps
-xa|");
#make sure ppp is not running
for( <InPipe>) {
$thisProc =
$_;
$thisProc =~ /([0-9]+).+\b[0-9]+\b\s(.*)$/;
# $1 is
PID; $2 is process name
$PID = $1; $NAME = $2;
if (
"$NAME" eq "PPPcommand" ) {
exit;
}
}
close
(InPipe);
# PPP not running; OK to start it;
system($PPPcommand);
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3.0.32.19691231210000.00a4ae50>
