import paramiko
host='x.x.x.x'
port=22
username='root'
password='password'
cmd='dmidecode > a'
ssh=paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host,port,username,password)
try:
stdin,stdout,stderr=ssh.exec_command(cmd)
outlines=stdout.readlines()
resp=''.join(outlines)
print(resp)
except paramiko.AuthenticationException as error:
print "ERROR"
{cdm>无法捕获^'。 有人能给我建议其他方法来避免破坏脚本只显示错误吗?在
^{} 发生在^{} :
并且您的
SSHClient.connect
调用不在您的try
块中。在这应该是有效的:
相关问题 更多 >
编程相关推荐