1

I'm new to python or any language but I'm trying to write this script to facilitate some tasks, I'm having this issue with the python telnetlib, that I'm trying to read the output of the ssh session with .read_until(comm_prompt) but it always seems to match the first prompt and not the last one, resulting in not showing the actual output, like this:

  while True:
    command = raw_input('Give me a command: ')
    expected = 'Switch#'
    tn.write(command+'\n')
    output = tn.read_until(expected)
    print output

This is what a get:

Give me a command: show version
Switch#

I was wondering how I would go about matching the second 'Switch#' or maybe there's another way around this. The reason I want to use .read_until method is because of speed.

Victor
  • 11
  • 2

1 Answers1

0

Just adding another read_until(expected) should do

Lou_is
  • 33
  • 7