From owner-freebsd-questions Tue Jun 9 05:24:10 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id FAA01333 for freebsd-questions-outgoing; Tue, 9 Jun 1998 05:24:10 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from server4.mpcbbs.com.br (server4.mpc.com.br [200.246.0.252]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id FAA01276 for ; Tue, 9 Jun 1998 05:24:02 -0700 (PDT) (envelope-from capriotti@geocities.com) Received: from hot_nt (d1p24.mpcnet.com.br [200.246.29.88]) by server4.mpcbbs.com.br (8.8.6/8.8.6) with SMTP id IAA28668 for ; Tue, 9 Jun 1998 08:32:05 -0300 (EST) Message-Id: <3.0.32.19691231210000.00a4ae50@pop.mpc.com.br> X-Sender: capriotti@pop.mpc.com.br X-Mailer: Windows Eudora Pro Version 3.0 (32) Date: Tue, 09 Jun 1998 08:31:59 -0300 To: freebsd-questions@FreeBSD.ORG From: Capriotti Subject: Perl to sh script Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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( ) { $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