Help with regex on telnet output

Adam Flott adam at npjh.com
Mon Jul 5 22:13:43 EDT 2004


I'm having some difficulty getting the expect function of telnetlib to
capture some data that gets returned from a telnet connection.

Python's telnet debug reports this:

recv 'whoami\n\r\xff\xfc\x01\r\nHi, my name is :     Home\r\nHere'
IAC WONT 1
recv ' is what I know about myself:\r\nModel:             '
recv '  VSX 7000\r\nSerial Number:       822232085C63K\r\nS'
recv 'oftware Version:    Release 1.0 - August 2001\r'
recv '\nBuild Information:   build at www.'
recv 'a.com\r\nFPGA Revision:       4.3.0\r\nMain Proc'
recv 'essor:      BSP15   v0.0 ~ Core/Mem Clks 415/111  '
recv '[3:4 0:3]\r\nTime In Last Call:   0:00:00\r\nTotal Tim'
recv 'e In Calls: 0:22:17\r\nTotal Calls:         18\r\nSNTP'
recv ' Time Service:   auto insync 21.1.1.1\r\nLocal Tim'
recv 'e is:        Mon,  5 Jul 2004 20:59:35 -0500\r\nNetw'
recv 'ork Interface:   ISDN_QUAD_BRI\r\nIP Video Number:  '
recv '   192.168.0.99\r\nISDN Video Number:   1.555.115047'
recv '4\r\nH323 Enabled:        True\r\nFTP Enabled:        '
recv ' True\r\nHTTP Enabled:        True\r\nSNMP Enabled:   '
recv '     True\r\nNIC Slot 1 SW Ver:   6.03\r\nNIC Slot 1 B'
recv 'oot Ver:   0.02\r\n\xff\xfb\x03'
IAC WILL 3
recv '\xff\xfc\x01'
IAC WONT 1
recv '\xff\xfb\x03'
IAC WILL 3

The call I made to expect including a timeout of 1 seconds, which is
plenty of time to wait for a response, but keeps repeating WILL 3/WONT 1
indefinitely. 

I only want to match from the begginning (\r\nHi. to the end 0.02\r\n).
This data is not specific and I just want data that looks like this
format to be returned from the call to expect. The only thing I've found
that is constant is a colon separates one side to the other.

Here is the start to the regular expression I've been trying to get to
work:

"^([\w\s]+?)(:)\s{1,}(.*):?\r\n$"

I'm using Python version: Python 2.3.4 (#2, Jun 19 2004, 18:15:30) on
Debian unstable

Any help or direction is appreciated.


Adam



More information about the Python-list mailing list