On Tue, 2007-11-13 at 21:54 +0530, Kumar Appaiah wrote:
> On Tue, Nov 13, 2007 at 03:32:39PM +0000, cs wrote:
> > #!/bin/bash -x
> > TEMPFILE=`mktemp /tmp/chk_procs_XXX`
> > trap 'date|mail -s "$0 error" [EMAIL PROTECTED];echo Error - aborting;\
> > exit' ERR
> > 
> > ### only allow one instance of this per user to run at a given time
> > ps -elf|grep $0|grep -v grep > $TEMPFILE
> > if [[ `cat $TEMPFILE | wc -l` -gt 1 ]]; then 
> >     #cat $TEMPFILE
> >     date | mail -s '${0} already Running' [EMAIL PROTECTED]
> >     rm $TEMPFILE
> >     exit -1
> > fi
> > rm $TEMPFILE
> > 
> > 
> > but that mails the string $0 not the value. Removing the quotes results
> > in an error.
> 
> If I recall correctly, single quote dumps values literally. You might
> want to use doublt quotes for the value of ${0} to be substituted,
> though I am not 100% sure that that will solve the problem.

Kumar, thanks for that. Embarrassingly, I'd already got it right (see
'trap') but for some reason (lack of coffee this morning?) I'd not tried
that for the second 'mail' command.

Many thanks, Michael


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to