Chinaunix
标题:
错在哪? 新手指教
[打印本页]
作者:
fllintel
时间:
2011-11-14 19:45
标题:
错在哪? 新手指教
import paramiko
def Myssh(ip,user,pw,pt):
myssh= paramiko.SSHClient()
myssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
myssh.connect(ip,username=user,password=pw,port=pt)
i,o,e=myssh.exec_command("ls")
print o.read()
myssh.close()
file=open("test.txt","r")
user="test"
for line in file.readlines():
x=line.split()
ip1=x[0]
pw1=x[1]
pt1=x[2]
print ip1,pw1,pt1
Myssh(ip1,user,pw1,pt1)
复制代码
执行后出现 :
127.0.0.1 abc123 22
Traceback (most recent call last):
File "myssh.py", line 22, in ?
Myssh(ip1,user,pw1,pt1)
File "myssh.py", line 9, in Myssh
myssh.connect(ip,username=user,password=pw,port=pt)
File "build/bdist.linux-i686/egg/paramiko/client.py", line 310, in connect
TypeError: int argument required
复制代码
我是想 去读一个文件, 里面有ip,密码 和 端口
然后在用ssh去连接...
可是搞不懂为啥出错了...请指教....
作者:
zcheung
时间:
2011-11-14 23:07
提示为类型错误。需要整形。
你看下paramiko.SSHClient.connect原型
作者:
lkk2003rty
时间:
2011-11-15 09:56
Myssh(ip1,user,pw1,pt1) ==> Myssh(ip1,user,pw1,int(pt1))
作者:
fllintel
时间:
2011-11-15 17:50
回复
3#
lkk2003rty
多谢多谢 恍然大悟啊~~
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2