From owner-freebsd-hackers Sun Jan 27 17:19:30 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from lists.unixathome.org (lists.unixathome.org [210.48.103.158]) by hub.freebsd.org (Postfix) with ESMTP id 3801B37B417 for ; Sun, 27 Jan 2002 17:19:26 -0800 (PST) Received: from wocker (lists.unixathome.org [210.48.103.158]) by lists.unixathome.org (8.11.6/8.11.6) with ESMTP id g0S1JHD97804 for ; Mon, 28 Jan 2002 14:19:18 +1300 (NZDT) (envelope-from dan@lists.unixathome.org) Message-Id: <200201280119.g0S1JHD97804@lists.unixathome.org> From: "Dan Langille" Organization: DVL Software Limited To: freebsd-hackers@freebsd.org Date: Sun, 27 Jan 2002 20:19:16 -0500 MIME-Version: 1.0 Subject: shell scripts that hang around forever Reply-To: dan@langille.org X-mailer: Pegasus Mail for Windows (v4.01) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Folks: have a look at this FreshPorts shell script and let me know if there is a better way to do this. This script waits for a file to arrive in a directory, then runs a scipt to process it. It's part of FreshPorts. the procmail script spools the incoming cvs-all message to a temporary location, then moves it to the incoming directory. The lockfile is an attempt to make the script single-entry (only one instance at a time). If fails because the only way to exit the script is to terminate it... At present, this script runs within a screen session (that's the easiest way to control it). This script is sort of like a daemon, and I'm tempted to replace it with one. If it was a daemon, I'm sure that would be much easier. #!/bin/sh LOCKFILE=${HOME}/msgs/processing.lock MSGSDIR=${HOME}/msgs/FreeBSD/incoming lockfile -r 0 $LOCKFILE RESULT=$? #echo result='$RESULT' if [ $RESULT = 0 ] then cd ${MSGSDIR} while . do FILECOUNT=`ls | wc -l` if [ $FILECOUNT -ne 0 ] then ls | xargs -n 1 $HOME/scripts/test-freebsd-cvs.sh fi sleep 1 done rm -rf ${LOCKFILE} fi -- Dan Langille The FreeBSD Diary - http://freebsddiary.org/ - practical examples To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message