read_until problem under telnetlib

Steve Horsley steve.horsley at cwcom.cwplc.com
Fri Jun 13 14:03:13 CEST 2003


david_martin at carrefour.com (dma2) wrote in message news:<b94c6ea6.0306110847.571d6690 at posting.google.com>...
> hi, i am having a problem that seems not to have been adressed yet on
> this list
> 
> i work on thousands of cisco equipements, and as usual the cisco
> prompt is not consistent across their whole range of equipements and i
> need this kind of code

expect() takes a LIST of strings, not a single string.
Also, it returns a tuple. This should work:

    index, match, got = cnx.expect(['#', '(enable)'], 5)
    if index == 0:
        print "it's an IOS box"
        doTheIosStuff()
    elif index == 1:
        print "it's a CatOS box"
        doTheCatosStuff()
    else:
        print "Urgh! Timeout."

Steve




More information about the Python-list mailing list