Forum Discussion

Richard_Jones's avatar
Richard_Jones
Icon for Nimbostratus rankNimbostratus
Jan 20, 2007

Parsing external class doesn't work like internal class

I am trying to parse an external file and load the strings into an array using this code:

 

 

class server_tasks {

 

type string

 

filename "/config/server_tasks"

 

}

 

class server_tasks2 {

 

"192.168.100.253 9"

 

"192.168.200.206 7"

 

"192.168.200.80 4"

 

}

 

 

/config/server_tasks contains:

 

"192.168.100.253 9",

 

"192.168.200.206 7",

 

"192.168.200.80 4",

 

 

This loop in RULE_INIT works:

 

foreach x $::server_tasks2 {

 

set ::servers([getfield $x " " 1]) [getfield $x " " 2]

 

log local0. "[getfield $x " " 1] has a count of $::servers([getfield $x " " 1])"}

 

 

I receive in the logs:

 

 

192.168.200.80 currently has 4 tasks

 

192.168.200.206 currently has 7 tasks

 

192.168.100.253 currently has 9 tasks

 

 

When I change the foreach to use $::server_tasks (the external class), I receive only the first line:

 

 

192.168.100.253 currently has 9 tasks

 

 

Any idea why I can't parse an external class like I can an internal class?
No RepliesBe the first to reply