Thank you, Seva. This worked.
Regards, j -----Original Message----- From: Seva Gluschenko [mailto:seva.glusche...@gmail.com] Sent: Tuesday, September 13, 2011 11:49 AM To: Jerome Yanga Cc: help-cfengine@cfengine.org Subject: Re: CFEngine Help: how to convert vars to a class Jerome, I guess, you want something like classes: "$(temp)" expression => "any"; 2011/9/13 Jerome Yanga <jya...@esri.com>: > Aleksey, > > I came up with the following but I seem to be misinterpreting the reference > manual. I have also used canonify to no avail. Help. > > $ cat /tmp/test.txt > DOG > > bundle common g > { > vars: > > "temp" string => readfile( "/tmp/test.txt" ); > } > > bundle agent animal > { > commands: > "/bin/echo $(g.temp)" > ifvarclass => "$(g.temp)"; > reports: > DOG:: > "I have a pet dog."; > } > > Regards, > j > > -----Original Message----- > From: Aleksey Tsalolikhin [mailto:atsaloli.t...@gmail.com] > Sent: Tuesday, September 13, 2011 11:20 AM > To: Jerome Yanga > Cc: help-cfengine@cfengine.org > Subject: Re: CFEngine Help: how to convert vars to a class > > Yes, you can do it using the ifvarclass, which converts a variable to > a class. Could you please read the ifvarclass section of the > reference manual, and let me know if you have any questions. > > Best, > Aleksey > > > On Tue, Sep 13, 2011 at 11:13 AM, Jerome Yanga <jya...@esri.com> wrote: >> Is it possible to do what I am attempting to? >> >> Regards, >> j >> >> -----Original Message----- >> From: Jerome Yanga >> Sent: Monday, September 12, 2011 4:27 PM >> To: 'Aleksey Tsalolikhin' >> Cc: 'help-cfengine@cfengine.org' >> Subject: RE: CFEngine Help: how to convert vars to a class >> >> Aleksey, >> >> Thank you for the quick response. >> >> My main objective is to make the contents of /tmp/test.txt into a class. >> Hence, I would like to do the reporting. >> >> bundle agent animal >> { >> reports: >> DOG:: >> "I have a pet dog."; >> } >> >> Regards, >> j >> >> -----Original Message----- >> From: Aleksey Tsalolikhin [mailto:atsaloli.t...@gmail.com] >> Sent: Monday, September 12, 2011 4:15 PM >> To: Jerome Yanga >> Cc: help-cfengine@cfengine.org >> Subject: Re: CFEngine Help: how to convert vars to a class >> >> On Mon, Sep 12, 2011 at 3:58 PM, Jerome Yanga <jya...@esri.com> wrote: >>> I saw another post on how to do this but it does not seem to work for me. >>> Please correct my syntax >> >> How's this? >> >> [cfengine00 ~]# cat /tmp/test.txt >> DOG >> [cfengine00 ~]# cat test.cf >> body common control { >> bundlesequence => { "animal" }; >> } >> >> bundle common g >> { >> vars: >> >> "temp" string => readfile("/tmp/test.txt", "4" ); >> } >> >> bundle agent animal >> { >> commands: "/bin/echo $(g.temp)"; >> commands: >> "/bin/echo I have a pet dog." >> ifvarclass => "$(g.temp)"; >> } >> [cfengine00 ~]# cf-agent -f ./test.cf >> Q: ".../bin/echo DOG": DOG >> I: Last 1 quoted lines were generated by promiser "/bin/echo DOG" >> [cfengine00 ~]# >> >> Note the use of ifvarclass attribute to use a variable as a class; and >> the full name of the variable (including the bundle name) in g.temp. >> CFEngine bundles have scope, so you have to use the full name to call >> a variable from another bundle (even a global variable). >> >> Yours, >> -at >> >> > > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@cfengine.org > https://cfengine.org/mailman/listinfo/help-cfengine > -- SY, Seva Gluschenko. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine