You could probably easily port the functionality you're looking for in using ReadTCP to netcat. Then you could either write a wrapper script that calls netcat, or just run netcat itself, inside of a ReturnsZero or ReturnsZeroShell function. Although you're obviating the usage of an internal cfengine function (boo) you're gaining the ability to more easily control the method of class expression (yay).
classes: locationX = ( ReturnsZero("/path/to/nc.script $dostuff") ) locationY = ( ReturnsZero("/path/to/nc.script $dootherstuff") ) -Chris On Thu, 18 Mar 2010, Aleksey Tsalolikhin wrote: > Hi. Is it possible to selectively suppress error messages with cfengine 2? > > For example, I have the following working config which sets a class indicating > the machine's physical location. > > I deal with two locations, and each location has it's own Web proxy server. > I try to connect to both, and set a class based on which one succeeds. > > --- start of cfengine 2.2.10 config file file --- > > #!/var/cfengine/bin/cfagent -qKf > > control: > > probehttphwd = ( ReadTCP(webproxy.hollywood.example.com,8008,"GET > /cfengine_probe HTTP/1.0${n}${n}",1024) ) > probehttpnyc = ( ReadTCP(webproxy.newyork.example.com,8008,"GET > /cfengine_probe HTTP/1.0${n}${n}",1024) ) > > > classes: > we_are_in_hollywood = ( RegCmp(".*HTTP.*","${probehttphwd}") ) > we_are_in_newyork = ( RegCmp(".*HTTP.*","${probehttpmmb}") ) > > --- start of cfengine 2.2.10 policy file --- > > However this results in error messages for the other proxy: > > Couldn't open a tcp socket > Connection timed out > > Is there any way to suppress just that error message? I searched the > Cfengine 2 reference manual and did not find anything so I suspect > the answer is "no", but maybe I missed something? > > I am trying to determine location. I can't use network addresses, > as these are separate entities each using private address space > and there is some overlap in the address space they use. > > Thanks, > Aleksey > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@cfengine.org > https://cfengine.org/mailman/listinfo/help-cfengine > _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine