help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Looping in shellcommands


From: Mark . Burgess
Subject: Re: Looping in shellcommands
Date: Thu, 1 Aug 2002 12:58:24 +0200 (MET DST)

You could do this either with a wrapper or, as you suggest,
by getting a list of dirs in a variable and setting SplitOn = ( " " )
to make it into an iterative list.

M


On 25 Jul, Christopher Browne wrote:
> I've got some situations where I need to run a command on each
> file/directory in a list.
> 
> It's not quite clear how to accomplish that.
> 
> What I have done is thus:
> 
> shellcommands:
>   chvatal::
>     # clean up SN news spool
>     "/bin/ls /var/spool/sn | /usr/bin/xargs -n 1 /usr/sbin/snexpire -5d"
> 
> What I'd _like_ to do is to set up a variable to contain all the
> directory names under /var/spool/sn, and invoke the snexpire script on
> each one.  Perhaps like:
> 
> control:
>   chvatal::
>     sndirs= ("exec /bin/ls /var/spool/sn")
> 
> shellcommands:
>   chvatal::
>     "/usr/sbin/snexpire -5d $(sndirs)"
> 
> although there's something not quite right there, as it doesn't _look_
> like that would be much of an "iterator."
> 
> In shell script, it would be something like:
> 
> for dir in `ls /var/spool/sn`; do
>   /usr/sbin/snexpire -5d $dir
> done
> 
> Am I trying to be overly clever?  To be sure, what I've got up top with
> the "xargs" does _work_.  But it seems likely there's a better "cfengine
> idiom" for it.
> --
> (concatenate 'string "cbbrowne" "@ntlug.org")
> http://www.ntlug.org/~cbbrowne/multiplexor.html
> Rules of the  Evil Overlord #207. "Employees will  have conjugal visit
> trailers which  they may use provided  they call in  a replacement and
> sign out on  the timesheet. Given this, anyone caught  making out in a
> closet  while  leaving  their   station  unmonitored  will  be  shot."
> <http://www.eviloverlord.com/>
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-cfengine



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272            Email:  Mark.Burgess@iu.hio.no
Fax : +47 22453205            WWW  :  http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





reply via email to

[Prev in Thread] Current Thread [Next in Thread]