Re: shell scripts that hang around forever
On Sun, 27 Jan 2002, Dan Langille wrote: Folks: have a look at this FreshPorts shell script and let me know if there is a better way to do this. You could avoid polling (at the expense of a fork) by using wait_on (PR #34414). Andrew To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message
Re: shell scripts that hang around forever
Dan Langille wrote: 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. Wouldn't the following change be helpful if you always ^C the script to stop it? #!/bin/sh LOCKFILE=${HOME}/msgs/processing.lock MSGSDIR=${HOME}/msgs/FreeBSD/incoming cleanup() { rm -rf ${LOCKFILE} exit } trap cleanup sighup sigint sigquit sigill sigabrt sigterm 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 cleanup fi -- \ |_ _|__ __|_ \ __| Jason Andresen[EMAIL PROTECTED] |\/ | ||/ _| Network and Distributed Systems Engineer _| _|___| _| _|_\___| Office: 703-883-7755 To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message
Re: shell scripts that hang around forever
Thank you Jason. Yes, it would be helpful. And I had wondered if that was possible. Cheers. FWIW: I am now testing the script using the ports/sysutils/daemontools utilities. That seems to be working well so far. I will be writing a daemontools article for the Diary and will post the URL here for feedback before I make it public. On 28 Jan 2002 at 10:14, Jason Andresen wrote: Wouldn't the following change be helpful if you always ^C the script to stop it? #!/bin/sh LOCKFILE=${HOME}/msgs/processing.lock MSGSDIR=${HOME}/msgs/FreeBSD/incoming cleanup() { rm -rf ${LOCKFILE} exit } trap cleanup sighup sigint sigquit sigill sigabrt sigterm 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 cleanup fi -- Dan Langille The FreeBSD Diary - http://freebsddiary.org/ - practical examples To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message
Re: shell scripts that hang around forever
On 27 Jan 2002 at 20:18, Dan Nelson wrote: In the last episode (Jan 27), Dan Langille said: Folks: have a look at this FreshPorts shell script and let me know if there is a better way to do this. Apart from maybe using echo instead of forking 'ls', and caching the list: while : ; do FILES=`echo *` if [ $FILES != * ] ; then for i in $FILES ; do $HOME/scripts/test-freebsd-cvs.sh $i ; done fi done it looks fine. Good ideas. Thanks. I'll go with that despite my being so proud of even *knowing* about xargs and wanting to use it -- Dan Langille The FreeBSD Diary - http://freebsddiary.org/ - practical examples To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message
Re: shell scripts that hang around forever
In the last episode (Jan 27), Dan Langille said: Folks: have a look at this FreshPorts shell script and let me know if there is a better way to do this. Apart from maybe using echo instead of forking 'ls', and caching the list: while : ; do FILES=`echo *` if [ $FILES != * ] ; then for i in $FILES ; do $HOME/scripts/test-freebsd-cvs.sh $i ; done fi done it looks fine. -- Dan Nelson [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message
Re: shell scripts that hang around forever
On 27 Jan 2002 at 20:18, Dan Nelson wrote: In the last episode (Jan 27), Dan Langille said: Folks: have a look at this FreshPorts shell script and let me know if there is a better way to do this. Apart from maybe using echo instead of forking 'ls', and caching the list: while : ; do FILES=`echo *` if [ $FILES != * ] ; then for i in $FILES ; do $HOME/scripts/test-freebsd-cvs.sh $i ; done fi done it looks fine. Thanks Dan. I'm also looking at ports/sysutils/daemontools for starting and making sure this service is always running. See http://cr.yp.to/daemontools.html -- Dan Langille The FreeBSD Diary - http://freebsddiary.org/ - practical examples To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message