When I run 'show version' on a Cisco switch I get the following output:
Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2011 by Cisco Systems, Inc.
<--output truncated-->
#
I am using Expect to login to the switch, run the show version command, and expect the complete output of that command and the exact version, which I can then output to the screen using the code below:
send "show version\n"
expect -re "show version.*Version (.*), REL.*#$"
send_user "Command Output:\n$expect_out(0,string)\n\n"
send_user "Version:\n$expect_out(1,string)\n\n"
This all works OK, however I am now trying to replicate this using Python and Pexpect. I can get the equivalent of $expect_out(0,string) using child.before:
child.sendline(show version')
child.expect('#')
print("\r\n","Command Output:","\r\n",child.before, sep = '')
How do I replicate $expect_out(1,string) in Pexpect to get the exact version?
Many thanks in advance