Re: splitstring(), or splitting a string into characters

2010-02-26 Thread daniel . klein
Jim- You're right, splitstring does not split on every character (and maybe it should if you specify a null pattern). And you missed on "." (because that makes every character a separator, and then there are no characters to separate) and on "[.]" (because a '.' in a [character class] is just a d

Re: load promise from file

2010-02-27 Thread daniel . klein
Niek- Only one set of promises is ever run. By default that comes from promises.cf, but you can specify an alternative set with -f. Those promises can consist of many other files, which you list in the inputs. Regardless of which files are included, the agent only runs the promises listed in th

Re: Editing known_hosts files

2010-03-01 Thread daniel . klein
In the latest version, look at regextract() - I think that'll help get the field you want, so you can do your insert... -Dan > No responses? Ok, let me restate the problem more simply. > > Given a file whose lines have three space-delimited fields, and given a > string variable that contains a s

Re: challenge: last Saturday of the month

2010-03-03 Thread daniel . klein
Save yourself two shell commands - if you invoke cal with no arguments, it gives you this month's calendar. So skip the first two calls to date :-) -Dan > okay, I got it. Kinda hacky with all the pipes: > > vars: > "year" string => execresult("/usr/bin/date +%Y","noshell"); > "mont

Re: Indexing an array of slist?

2010-03-05 Thread daniel . klein
The quick answer is "you don't". The longer answer is: an slist (or ilist or rlist) can only be iterated over in it's entirety by referencing the list as a scalar (and then cfengine iterates over the whole list automagically). You can index an array (which is what 'foo' is in your example), but a

Re: Basic string replacement

2010-03-05 Thread daniel . klein
Because it is a declarative promise language - which is somewhat different than the usual imperative programming language model. A fine point, but different nontheless. Declarative languages are hard to get your head around if you think in purely imperative terms. Once you "let go" and allow you

Re: this.promiser with copy_from

2010-03-09 Thread daniel . klein
Which version of Cfengine? This was a recently reported bug, but I don't know if it is in the patchset yet... -Dan > --_002_2BF070A7A2375D46BA1B6087F8D5DCB678AFEF7C48seldmbx01corp_ > Content-Type: text/plain; charset="us-ascii" > Content-Transfer-Encoding: quoted-printable > > Hi, > > Is there

Re: this.promiser with copy_from

2010-03-09 Thread daniel . klein
Yep, you're definitely going to see the bug, then. The report was against 3.0.3, and I *think* it is fixed in 3.0.4 -Dan > Ok, great :-) I'm running 3.0.3patch1. > > > Best regards, > Emil Assarsson emil.assars...@sonyericsson.com > Phone: +46 (0)10 8017422 > > > > > -Original Message-

Re: any good abstract solution for action upon file change?

2010-03-23 Thread daniel . klein
Seva- What you probably want to do is package everything into a method. So, something like this (I haven't checked it for syntax, I am just typing to give you an idea). Note that you'll be saving space sometimes and wasting sometimes depending on how many times you need to re-do a task, so my ex

Re: Cfengine Help: Re: Cfengine Help: methods and undeclared bundles

2010-03-24 Thread daniel . klein
The issue is that Cfengine does a fair amount of compile-time checking and optimization, and if you want to think of it this way, tweaking the bundlesequence with "ignore_missing_bundles" is a pre-processor tweak (where you can say "continue somiling if this bundle is missing"), whereas methods pro

Re: Cfengine3: Interface Naming when Building Firewall Rulesets from Templates

2010-03-25 Thread daniel . klein
FWIW, I see a possibly related bug in $(sys.interface). However, I still need to upgrade to the latest versions, so please submit a bugreport based on your version. To answer your question, you can use getindices to find out all the interface names that are active (i.e., have an IP address). bod

Re: variables expansion in edit_line

2010-03-29 Thread daniel . klein
You have a problem here: groupX:: "extra_line"string => "57 10 * * * root nice -n -1 $(path)/$(id)-$(extra).sh"; The problem is that $(extra) is an slist, so you are iterating over it, and that redefines the "extra_line" variable. It's as if you said: groupX::

Re: Loop through file in cfengine3?

2010-04-12 Thread daniel . klein
Look at the readstringlist and readstringarray builtin functions. Also, see http://www.cfengine.org/manuals/cf3-reference.html#Introduction-to-functions which is a handy guide to which functions return what (once you've perused the whole list to get familiar with them, of course :-) -Dan > I hav

Re: matching a new [section] or EOF with select_end in a select_region body

2010-04-13 Thread daniel . klein
If you leave off the "select_end", it will match from the select_start to the end of file. If you have both a select_start and a select_end, then it will match between those - and in a recent patch, it will also allow EOF to match the end. You'll need the newer code, though... -Dan > Hi, > > D

Re: Cfengine Help: Re: RE: Cfengine Help: cfengine program flow

2010-04-21 Thread daniel . klein
Kinda-sorta :-) Classes that are defined in a "common" bundle are global. Classes that are defined in any other kind of bundle are local to that bundle. See section 1.6 of the manual. Likewise, classes are cached with an expiration time, but they do go away. Although they can be set with a test

Re: how to get the index of a list

2010-04-29 Thread daniel . klein
You probably want to to a classmatch() against the hostname to determine which machine you are on - and take it from there... -Dan > --===0023485862== > Content-Type: multipart/alternative; > boundary="=_Part_150839_55279.1272591905086" > > --=_Part_150839_55279.127259

Re: action for all classes exclude one

2010-05-31 Thread daniel . klein
To further clarify what Seva said (which is 100% correct :-), you don't need to say "any.!foo" - if you say "!foo" it means "not foo" which includes "anything else" :-) -Dan > bundle common c > { > classes: > "sf_group" expression => classmatch("sf_.*"); > } > > body common control > { >

Re: rename => rotate and depth_search => recursion

2010-06-04 Thread daniel . klein
This is the root of the problem: file_select implies a search - and the only way you can have a search is either with depth_search or a wildcard in the filename I believe this is also a bug, in that Cfengine should tell you when you have a promise that cannot be satisfied, and requires a componen

Re: glob in inputs

2010-06-04 Thread daniel . klein
You can work around the '*' restriction if you like, but wildcard matching on inputs is a security risk. The reason is as follows: 1) Assume there is a inputs => { "xxx/*.cf" }; in your promises.cf 2) You do testing in a different directory other than /var/cfengine/inputs (this is a good idea

Re: append value to variable slist

2010-06-04 Thread daniel . klein
I agree with Seva, and also point out that by trying a list append, you are still thinking procedurally and not declaratively... Procedural programming (and thinking) says "do X, then Y, then Z" Declarative programming (which is what Cfengine is) says "make sure that X, Y and Z are all satisfied"

Re: Cfengine Help: Re: When will locks be removed?

2010-06-23 Thread daniel . klein
I will be updating the documentation :-) > This is exactly what I was hoping for :-) > The documentation could use an update on this. > > -- > Emil > > -Original Message- > From: help-cfengine-boun...@cfengine.org [mailto:help-cfengine-boun...@cfengi > ne.org] On Behalf Of no-re...@cfeng