Sorry you are right, I forgot to put my code:
I tried this code an sometimes is working and you can get the result, but sometimes is not working, I can't understand how it is working sometimes and others not, I was playing with the clear buffers and timeouts and its appears to be affected to all the execution.
I don't knwo if this type of code is correct or not to jump from one device to another "both router cisco" in this case.
Thanks for your help.
jumpserver = {'device_type' : 'cisco_ios','ip' : ipNoc,'username':userNoc,'password' : passNoc}
for x in range(1,len(first_column)-1):
host=first_column[x].value
print("")
print (" SSH Session Established with " + ipNoc + " ....")
net_connect = ConnectHandler(**jumpserver)
print("")
print (" Interactive Session Established with " + ipNoc + " ....")
print ("")
net_connect.clear_buffer()
output=net_connect.find_prompt()
print("Trying to connecting from " + output + " to " + host +".test.net")
net_connect.clear_buffer()
net_connect.settimeout(None)
net_connect.write_channel("ssh -l "+ userAtt + " " + host +".test.net")
print("")
print (" SSH Session Established with " + host + " ....")
time.sleep(4)
net_connect.send_command('password' + "\n")
print("")
print (" Interactive Session Established with " + host + " ....")
print ("")
net_connect.clear_buffer()
net_connect.read_channel()
redispatch(net_connect, device_type='cisco_ios')
output=net_connect.find_prompt()
print(output)
output=net_connect.send_command('sh ver')
print(output)
time.sleep(timeout_modifier)
I tried this code an sometimes is working and you can get the result, but sometimes is not working, I can't understand how it is working sometimes and others not, I was playing with the clear buffers and timeouts and its appears to be affected to all the execution.
I don't knwo if this type of code is correct or not to jump from one device to another "both router cisco" in this case.
Thanks for your help.
jumpserver = {'device_type' : 'cisco_ios','ip' : ipNoc,'username':userNoc,'password' : passNoc}
for x in range(1,len(first_column)-1):
host=first_column[x].value
print("")
print (" SSH Session Established with " + ipNoc + " ....")
net_connect = ConnectHandler(**jumpserver)
print("")
print (" Interactive Session Established with " + ipNoc + " ....")
print ("")
net_connect.clear_buffer()
output=net_connect.find_prompt()
print("Trying to connecting from " + output + " to " + host +".test.net")
net_connect.clear_buffer()
net_connect.settimeout(None)
net_connect.write_channel("ssh -l "+ userAtt + " " + host +".test.net")
print("")
print (" SSH Session Established with " + host + " ....")
time.sleep(4)
net_connect.send_command('password' + "\n")
print("")
print (" Interactive Session Established with " + host + " ....")
print ("")
net_connect.clear_buffer()
net_connect.read_channel()
redispatch(net_connect, device_type='cisco_ios')
output=net_connect.find_prompt()
print(output)
output=net_connect.send_command('sh ver')
print(output)
time.sleep(timeout_modifier)