[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Looping in shellcommands
From: |
Christopher Browne |
Subject: |
Looping in shellcommands |
Date: |
Thu, 25 Jul 2002 12:23:21 -0400 |
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/>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Looping in shellcommands,
Christopher Browne <=