From owner-freebsd-questions@FreeBSD.ORG Thu May 13 20:21:58 2004 Return-Path: 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 33AC316A4CE for ; Thu, 13 May 2004 20:21:58 -0700 (PDT) Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9371743D46 for ; Thu, 13 May 2004 20:21:57 -0700 (PDT) (envelope-from apeiron@comcast.net) Received: from prophecy.velum (pcp08490587pcs.levtwn01.pa.comcast.net[68.83.169.224]) by comcast.net (sccrmhc11) with SMTP id <2004051403215601100q3hije> (Authid: apeiron@comcast.net); Fri, 14 May 2004 03:21:56 +0000 Date: Thu, 13 May 2004 23:21:51 -0400 From: Christopher Nehren To: JJB Message-ID: <20040514032151.GA11016@prophecy.dyndns.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="yrj/dFKFPuw6o+aM" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i cc: FreeBSD Questions List Subject: Re: perl pause or wait X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2004 03:21:58 -0000 --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable JJB wrote: >I have perl script that issues the newsyslog command followed by 3 >perl scripts that process the new .0 rotated file. > >Problem is the newsyslog rotate has not completed creating the new >.0 and rolling through the other .x files before the first perl >script in trying to open the .0 file for processing. > >Is there in perl pause or wait command I can use to allow some time >to elapse before continuing with the launch of the next script? Using a statement that delays for a specified period of time is a generally bad idea because you can't guarantee that the operation will complete in that time. Hence, you should look into filesystem locking functions: 'perldoc -f fcntl', 'perldoc -f flock', and 'perldoc -f lock'. Alternatively, you could use the four-argument form of select to receive information about when the files are available, but that's probably too complicated for what you want to do. Reading through 'perldoc perlipc' is advised for what you want to do. Granted, it's not traditional IPC, but architecting some IPC would help to guarantee that you're not processing the files before they're ready. Yet _another_ possible solution: why do you have four scripts? Can you not do what you want with one well-structured script? Perl has virtually all of the branching constructs of C, and some of its very own. --=20 I abhor a system designed for the "user", if that word is a coded pejorative meaning "stupid and unsophisticated". -- Ken Thompson - Unix is user friendly. However, it isn't idiot friendly. - Please CC me in all replies, even if I'm on the relevant list(s). --yrj/dFKFPuw6o+aM Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFApDtPk/lo7zvzJioRAksoAKCx6gLVmoWyxAu7PAbX1Qf3PKVhVgCguOoe 6z7+uyXAbVoucetNT3PgXbA= =dGmS -----END PGP SIGNATURE----- --yrj/dFKFPuw6o+aM--