Xymon Mailing List Archive search

bb-services: regexes in expect string?

3 messages in this thread

list Aaron Zink · Wed, 2 Jul 2008 12:33:08 -0700 ·
I have this defined in bb-services:

[smtp-transaction]
        send "helo hobbit.domain.com\r\nmail from: <user-a3d973489fd1@xymon.invalid>\r\nrcpt to: <user-f1d73117a4d8@xymon.invalid>\r\nquit\r\n"
        expect "220-mx01.domain.com ESMTP\r\n220 ESMTP READY\r\n250 mx01.domain.com\r\n250 sender <user-a3d973489fd1@xymon.invalid> ok\r\n"
        port 25

and a host that uses it in bb-hosts.  This works great, except that it's tied to the host mx01.domain.com in the expect string.

Is it possible to use regexes in the expect string, such as expect "220-mx0[0|1].domain.com"?  So far my attempts have been unsuccessful and the man pages don't seem to indicate if this is possible.


Aaron Zink
Manager, Corporate IT
eHarmony.com
XXX.XXX.XXXX
list Kolbjørn Barmen · Wed, 24 Mar 2010 08:52:58 +0100 (CET) ·
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
list Johan Karlsson · Tue, 21 Sep 2010 10:11:26 +0200 ·
I never saw a reply to this, so I'll bump it since I have exactly the same need ;)

Regards,

Johan
quoted from Kolbjørn Barmen

-----Original Message-----
From: Kolbjørn Barmen [mailto:user-5623b4f246b3@xymon.invalid] 
Sent: den 24 mars 2010 08:53
To: user-ae9b8668bcde@xymon.invalid
Subject: Re: [hobbit] bb-services: regexes in expect string?

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