From owner-freebsd-questions@FreeBSD.ORG Thu Dec 8 05:17:07 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 737AC16A41F for ; Thu, 8 Dec 2005 05:17:07 +0000 (GMT) (envelope-from akbeech@gmail.com) Received: from vfemail.net (miwi2dsl-a234.wi.tds.net [216.170.248.235]) by mx1.FreeBSD.org (Postfix) with ESMTP id B8E8743D5A for ; Thu, 8 Dec 2005 05:17:06 +0000 (GMT) (envelope-from akbeech@gmail.com) Received: (qmail 75214 invoked by uid 85); 8 Dec 2005 05:17:02 -0000 Received: from akbeech@gmail.com by mail.vfemail.net by uid 0 with qmail-scanner-1.16 (clamscan: 0.75.1. spamassassin: 2.63. Clear:. Processed in 1.666423 secs); 08 Dec 2005 05:17:02 -0000 Received: from unknown (HELO ?192.168.241.108?) (alaska@vfemail.net@24.237.206.237) by miwi2dsl-a234.wi.tds.net with RC4-MD5 encrypted SMTP; 8 Dec 2005 05:17:00 -0000 From: Beecher Rintoul Organization: NorthWind Communications To: Martin Cracauer Date: Wed, 7 Dec 2005 20:16:31 -0900 User-Agent: KMail/1.8.3 References: <200512071847.05393.akbeech@gmail.com> <20051208035255.GD33064@dan.emsphone.com> <20051207233359.B36369@cons.org> In-Reply-To: <20051207233359.B36369@cons.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3394482.d09tm9xW0j"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200512072016.58524.akbeech@gmail.com> Cc: Dan Nelson , freebsd-questions@freebsd.org Subject: Re: simple shell script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2005 05:17:07 -0000 --nextPart3394482.d09tm9xW0j Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Wednesday 07 December 2005 07:33 pm, Martin Cracauer wrote: > Dan Nelson wrote on Wed, Dec 07, 2005 at 09:52:55PM -0600: > > In the last episode (Dec 07), Beecher Rintoul said: > > > I'm trying to write a simple shell script that will launch a program > > > (in this case lynx), wait 60 seconds and then kill it. I can get it > > > to launch the program, but it seems to ignore anything after that. I > > > am not a programmer so does anyone have a suggestion on this script? > > > Any help would be appreciated. > > > > You need to background it so your script keeps running: > > > > #! /bin/sh > > # Launch program > > lynx & > > # Store its processid for later > > pid=3D$! > > # 60 seconds > > sleep 60 > > # Kill backgrounded process > > kill -9 $pid > > This is probably not what Beecher wants, he/she probably needs the > lynx in the foreground. > > In a pure shell script that is difficult because you cannot get the > pid of a foreground process without reverting to `ps` which is not > sportish. > > It's better to use a dedicated timeoput mechanism, e.g.: > http://cracauer-forum.cons.org/forum/cratimeout.html > > Then you can do `cratimeout 60000 lynx` > > Martin Thanks to you both, I missed the background option. Actually it just needs = to=20 run in the background to log some hits on a free webserver that I use for=20 testing. I forget and they will cancel my account if there's no traffic for= a=20 month. The timeout also looks interesting and I'll look into it. Beech =2D-=20 =2D------------------------------------------------------------------------= =2D------------- Beech Rintoul - System Administrator - akbeech@gmail.com /"\ ASCII Ribbon Campaign | NorthWind Communications \ / - NO HTML/RTF in e-mail | 201 East 9th Avenue Ste.310 X - NO Word docs in e-mail | Anchorage, AK 99501 / \ - Please visit Alaska Paradise - http://akparadise.byethost33.com =2D------------------------------------------------------------------------= =2D------------- --nextPart3394482.d09tm9xW0j Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQBDl8HKVq19LUoGB+MRAld0AKCa9FUb7aMRFmo2kb7mMTKEgWpm5wCfQfMB BfXaSJsVsvLkxgpGLZ13FrE= =MQiF -----END PGP SIGNATURE----- --nextPart3394482.d09tm9xW0j--