
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi all,
I am trying to code a script which will login into HPNA then connect to a device and execute a command and receive the output. Like
Using Python pexpect. Steps inside script I am following is
1. Using pexpect connect to NA Proxy
2. Execute "Connect <device_ip>"
3. On connected device , execute "show version"
4. Get "show version" output to a variable, using "child.before"
Everything works fine except #4. I am getting nothing as show version output.
But If use same env and script to login/ssh directly to device and execute the "show version" I get output to my variable child.before.
Also if using script, I login into NA Proxy and execute any local command (for ex : show task) I see child.before output.
Only when script login to NA proxy and then connect to another device and execute command, command output or child.before is blank.
Can someone please help .
--------------------------- Python Script ~~~~~~~~~~~~~~~~~~~~~~~~
# Connecting to HP NA cli
child = pexpect.spawn('ssh -l %s %s -p %s %s' %(HostTacUser,HostName,ssh_port,SSH_OPTIONS))
child.delaybeforesend = 0.05
child.expect('assword:', timeout=20)
child.sendline(HostTacPass)
child.expect ('NA>')
logfile_prefix = str(time.time());
logfile = "/tmp/ACI_BUG_CHECK_"+logfile_prefix
print "Log File : %s" % logfile
child.logfile = open(logfile, "w")
#Connecting to a Cisco device from HP NA cli
child.sendline('connect 10.1.1.1')
index = child.expect (["[a-z|A-Z|0-9|\-]{3,30}>","]#",pexpect.EOF, pexpect.TIMEOUT], timeout=20)
child.sendline('show version')
index = child.expect (["[a-z|A-Z|0-9|\-]{3,30}>","]#",pexpect.EOF, pexpect.TIMEOUT], timeout=20)
show_out = []
if index == 0:
show_out = child.before.splitlines()
------------------------
but show_out doesnt contain any output
Thanks
Bobin
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hello,
Please refer to the original thread :
Regards,
Customer Support Engineer
If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation. “


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hello,
Please refer to the original thread :
Regards,
Customer Support Engineer
If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation. “