- 论坛徽章:
- 0
|
#!/usr/bin/env python
#-*-coding:utf-8-*-
import os,sys
import re
import paramiko
import threading
import socket
def ssh(IP,PORT,USER,PASSWORD):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(IP,PORT,USER,PASSWORD,timeout=5)
ssh.close()
for list in open('aa.txt','r').readlines():
lineList=list.split('\t')
SITE=lineList[0]
IP=lineList[1]
USER=lineList[2]
PASSWORD=lineList[3]
PORT=lineList[4]
ssh(IP,PORT,USER,PASSWORD)
发现这样写,不能正常执行,IP,PORT,USER,PASSWORD变量不能获取到值
Traceback (most recent call last):
File "cc.py", line 20, in <module>
ssh(IP,PORT,USER,PASSWORD)
File "cc.py", line 11, in ssh
ssh.connect(IP,PORT,USER,PASSWORD,timeout=5)
File "build/bdist.linux-i686/egg/paramiko/client.py", line 287, in connect
socket.gaierror: (-8, 'Servname not supported for ai_socktype') |
|