ssh - Python Paramiko exec_command doesn't print few commands outputs -
i trying build python script using paramiko should ssh linux server , execute command, commands output working example df -f,netstat
of them aren't example onstat -,ifconfig
. need solving issue.
#!/usr/pkg/bin/python #importing modules import paramiko import time #setting parameters host ip, username, passwd , number of iterations gather cmds host = 'x.x.x.x' user = 'abc' pass = 'efg' iteration = 3 client1=paramiko.sshclient() #add missing client key client1.set_missing_host_key_policy(paramiko.autoaddpolicy()) #connect cucm client1.connect(host,username=user,password=pass) print("ssh connection %s established" %host) #gather commands , read output stdout stdin, stdout, stderr = client1.exec_command("onstat -") time.sleep(2) line in stdout.readlines(): print(line) client1.close() print("logged out of device %s" %host)
any thought how resolve this?
Comments
Post a Comment