On Tue, 22 Aug 2006 16:00:37 -0400, Bob Norfolk <punkrockgeekboy / yahoo.com> wrote: > John Johnson wrote: >> On Sat, 19 Aug 2006 20:59:15 -0400, John Johnson <johnatl / mac.com> >> wrote: >> >>> JJ >>> >> >> So, did it work? > > Actually, I was just working on debugging this error that the script > above gives : > > > nagiostest3.rb:111:in `initialize': (eval):1:in `initialize': compile > error (SyntaxError) > (eval):1: unterminated string meets end of file > (eval):1: parse error, unexpected $, expecting ')' > íelf.last_time_critical = Marshal.load(u: Time > ^ > from nagiostest3.rb:108:in `initialize' > from nagiostest3.rb:104:in `initialize' > from nagiostest3.rb:119 > Hm, probably a ' in the dumped data. Try this instead: def initialize(filename) super contents = File.open(filename).read contents.scan(SERVER_RE) { |value_ary| values = value_ary[0] host_name = "" service = OpenStruct.new values.scan(VALUE_RE) { |name, value| converted = convert_field(name, value) dumped = Marshal.dump(converted) dumped = dumped.unpack("H*") service.instance_eval( "self.#{name} = Marshal.load(['#{dumped}'].pack('H*'))") host_name=value if name == HOST_NAME_PROPERTY } self[host_name] = service } end end It converts the dumped data to a hex string, then back, eliminating the need for escaping characters, etc. Regards, JJ -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/