fgimian / paramiko-expect

A Python expect-like extension for the Paramiko SSH library which also supports tailing logs.
MIT License
204 stars 78 forks source link

Expect function not matching #6

Closed talbiston closed 9 years ago

talbiston commented 9 years ago

I really like this module but im running into an issue getting the "expect" function to work correctly. It seems as though its not reading the data form the buffer. Im no Python Wiz so im not totally sure what the issue is but i can supply the error.

The code Logs in to the router just fine and the prompt i will get back is "FW80CM3911602851 #" in my out put i do get "FW80CM3911602851 #" displayed back to the console but expect never matches the out put.

im just matching this exactly just to make sure its matching correctly .. The issue is it dose not seem to be working .

Below is my testing code:

!/usr/bin/python2

import paramiko from paramikoe import SSHClientInteraction import traceback

def Main():

try:

    hostname = 'example.us'
    username = 'Uname'      
    password = 'passWord'  

    s = paramiko.SSHClient()
    s.load_system_host_keys()
    s.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    s.connect(hostname=hostname, username=username, password=password)
    interact = SSHClientInteraction(s, timeout=10, display=True)
    if interact.expect(re_strings='FW80CM3911602851 # ', timeout=60):
        print "passed"

except Exception:
    traceback.print_exc()
finally:
    try:
        s.close()
    except:
        pass

if name == "main": Main() author = 'todd'

Out put =

/usr/bin/python2.7 /home/todd/PycharmProjects/paramikoe-test/Main.py FW80CM3911602851 #

Traceback (most recent call last): File "/home/todd/PycharmProjects/paramikoe-test/Main.py", line 24, in Main if interact.expect(re_strings='.FW80CM3911602851 # ', timeout=60): File "/usr/local/lib/python2.7/dist-packages/paramikoe.py", line 122, in expect buffer = self.channel.recv(self.buffer_size) File "/usr/lib/python2.7/dist-packages/paramiko/channel.py", line 619, in recv raise socket.timeout() timeout

Process finished with exit code 0