[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ReadArray functionality a bit wierd?
From: |
Steve Wray |
Subject: |
ReadArray functionality a bit wierd? |
Date: |
Thu, 18 Aug 2005 11:32:04 +1200 |
User-agent: |
Mozilla Thunderbird 0.9 (X11/20041103) |
Or is it me?
The attached cfengine script and data file has some interesting results.
1. When I use an explicit path to the config file in the ReadArray, it
seems to work pretty well as expected.
However, thats a bit unwieldy so I tried it with a variable instead:
this seems to break things horribly. The attached script is 'teh broken'
version.
Heres what cfrun -- -K -DTestingArray produces:
cfengine:cfserver: Executing script /bin/echo
$(testarray[one])...(timeout=0,uid=-1,gid=-1)
cfengine:cfserver:/bin/echo $(tes: sh: line 1: testarray[one]: command
not found
cfengine:cfserver: Finished script /bin/echo $(testarray[one])
cfengine:cfserver: Executing script /bin/echo
$(testarray[one])...(timeout=0,uid=-1,gid=-1)
cfengine:cfserver:/bin/echo $(tes: sh: line 1: testarray[one]: command
not found
cfengine:cfserver: Finished script /bin/echo $(testarray[one])
cfengine:cfserver:
ReadArray(/scratch/cfengine/masterfiles/hosts/cfserver/config/testdata,textkey,",","#",100)
cfengine:cfserver: $(testarray[one])
cfengine:cfserver: $(testitem)
So it looks as if, with the $() variable for an input file, ReadArray
just returns itself as a return string, as I see from the output of the
'alerts', specifically where the alert spits out the entire 'ReadArray'
line.
When I use an explicit path in the ReadArray it spits out '$(testarray)'
at that point which, I presume, is 'correct' for a defined assoc array
variable?
2. Iteration within array items doesn't seem to work, ie this:
control:
testlist = ( "one:two" )
testarray = ( A(one,1) A(two,2) )
shellcommands:
"$(echo) $(testarray[$(testlist1)])"
gives a cfengine syntax error:
cf:cfengine::/var/lib/cfengine2/inputs/testing.cf:30: Non identifier
character (:) in variable identifier (testarray[one:two])
It seems that one can't use list iteration as an array key even in a
location which normally supports iteration?
My thoughts on these issues are that cfengine could do with a decent
test suite and specifically some regression testing.
control:
TestingArray::
echo = ( "/bin/echo" )
actionsequence = ( shellcommands )
conffile = (
"/scratch/cfengine/masterfiles/hosts/cfserver/config/testdata" )
# testarray = ( ReadArray($(conffile),textkey,",","#",100) )
testarray = ( A(one,1) A(two,2) )
testlist = ( "one:two" )
# This is how the reference guides small and incomplete example uses
assoc arrays:
testitem = ( "$(testarray[one])" )
shellcommands:
TestingArray::
# All of these should echo '1'?
"$(echo) $(testarray[one])"
# produces: '1'
"$(echo) $(testitem)"
# produces: '1'
# should echo '1' and then '2' but in fact produces a cfengine syntax
error
# on parsing:
# "$(echo) $(testarray[$(testlist)])"
# cf:cfengine::/var/lib/cfengine2/inputs/testing.cf:30: Non identifier
character (:) in variable identifier (testarray[one:two])
alerts:
TestingArray::
"$(testarray)"
# produces: $(testarray)
"$(testarray[one])"
# produces: '1'
"$(testitem)"
# produces: '1'
one,1
two,2
signature.asc
Description: OpenPGP digital signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- ReadArray functionality a bit wierd?,
Steve Wray <=