[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: exec help?
From: |
Adrian Phillips |
Subject: |
Re: exec help? |
Date: |
14 Sep 2001 07:25:50 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
>>>>> "David" == David C Zemke <dzemke@auctionwatch.com> writes:
<snip>
David> hostname = ( "exec /bin/hostname | sed -e 's/[0-9].*//'" )
David> The above command works fine from the command line, but is
David> not evaluated properly by cfengine. Using the -v -d2
David> option, it looks like it evaluates to the entire string in
David> the above quotes (e.g. exec /bin/hostname | sed...)
<snip>
Yes, I have had the same problem, the solution for piping is to call
/bin/sh :-
test = ( "exec /bin/sh -c 'echo here is a test | cat'" )
BUT you're going to get into quoting difficulties very fast, so I've
done this using plugins :-
actionsequence = (
"module:definfo"
)
And in CFINPUT/modules/module:definfo (a cut down version shown here)
:-
#!/bin/sh
#
# Generate many of the vars and some classes used by cfengine
# Function to do the printing for vars
# first param is var name, second is value or use
# the value of the first if no second is given
function print_var () {
echo =$1=${2:-${!1}}
}
# Function to do the printing for classes
# first param is class name
function print_class () {
echo +$1
}
boot_partition=`df / | awk '/dev/ { print $1 }'`
print_var boot_partition
And so on.
Sincerely,
Adrian Phillips
--
Your mouse has moved.
Windows NT must be restarted for the change to take effect.
Reboot now? [OK]
- exec help?, David C. Zemke, 2001/09/13
- Re: exec help?,
Adrian Phillips <=