[hobbit] bb-services: regexes in expect string?

Kolbjørn Barmen kolbjorn.barmen at uninett.no
Wed Mar 24 08:52:58 CET 2010


On Wed, 2 Jul 2008, Aaron Zink wrote:

> Is it possible to use regexes in the expect string?

I'm wondering about the same, and haven't seen any answer to this.

I'm trying to match some xml, and first line is:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

The problem is the quotes, as bbtest-net terminates the string on the
first quote, no matter what, it seems.

I have tried escaping like this:
expect "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"

but "bbtest-net --services" shows "Exp.text: <?xml version=", adding more
\ doesnt help, the extra \ will then just be part of Exp.text.

I notice that --services show:
   Exp.text: <?xml version=
   Exp.len : 14
   Exp.ofs : 0

All my services show "Exp.ofs : 0", I suppose "ofs" means offset?
Is there a way to set this to something else than 0?

The services I try to monitor also seems to puke out some ctrl-chars at
the start (and it it uses ssl), a connection with openssl s_client looks
like this:

[snip SSL stuff]
    Verify return code: 19 (self signed certificate in certificate chain)
---
^@^@^D<FE><?xml version="1.0" encoding="UTF-8" standalone="no"?>
[snip rest of xml]

Should my "expect" also include "\x00\x00\x04\xFE" before "<?xml version"?

Again, if I could use regexp, I would probably just go for ".*<?xml ..",
and if offset can be used, I'd jump over the control chars.

Any tip?

-- 
Kolbjørn Barmen
UNINETT Driftsenter



More information about the Xymon mailing list