[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: embedded scripts [was: cfengine ideology question]
From: |
Brendan Strejcek |
Subject: |
Re: embedded scripts [was: cfengine ideology question] |
Date: |
Thu, 15 Apr 2004 12:55:29 -0500 |
User-agent: |
Mutt/1.3.28i |
Billy Allan wrote:
> On another note though, I was wondering if it might be useful to be able
> to embed small scripts in an arbitory scripting language
> (shell/perl/python/whatever) in a conf file and have cfengine call the
> interpretor.
>
> Something like :
>
> perl = ( /apps/perl )
> sh = ( /bin/sh )
>
> ...
>
> scripts:
> solaris.Hr00.Min0_5::
> perl {
> for ($i = 0; $i < 10; $i++) {
> print "hello world\n";
> }
> }
>
> patch_server.Hr00.Min0_5::
> sh {
> cd /export/patches/
> /apps/wget ftp://some.site.com/8_Recommended.zip
> /apps/unzip -q 8_Recommended.zip
> }
cfengine actually already has this functionality, though it is sort of
a hack. You can use multiline shellcommands. For example:
control:
actionsequence = ( shellcommands )
perl_bin = ( ExecResult(/usr/bin/which perl) )
shellcommands:
"${perl_bin} -e '
for (${dollar}i = 0; ${dollar}i < 10; ${dollar}i++) {
print \"hello world\n\";
}'
"
This is not taht different that what you wrote above. The only problem
is making sure that cfagent's variable interpolation does not mess up
the final script passed to the interpreter. Hence the ${dollar}.
I actually use little bits like this frequently.
- cfengine ideology question, Lev Lvovsky, 2004/04/14
- Re: cfengine ideology question, Tim Nelson, 2004/04/14
- Re: cfengine ideology question, Mark . Burgess, 2004/04/15
- methods and scripts [was: Re: cfengine ideology question], Tim Nelson, 2004/04/15
- Re: methods and scripts, Brendan Strejcek, 2004/04/15
- Re: methods and scripts, John Sechrest, 2004/04/15
- Re: methods and scripts, Chris Edillon, 2004/04/15
- Re: methods and scripts, Brendan Strejcek, 2004/04/15