import os
import sys
import datetime
import paramiko
username='root'
password='123456'
port=22
ip_list=['192.168.1.234',
'192.168.1.101'
]
local_file='/data/python/zhongwen.py'
remote_file='/data/testdir/zhongwen.py'
for ip in ip_list:
t=paramiko.Transport((ip,port))
t.connect(username=username,password=password)
sftp=paramiko.SFTPClient.from_transport(t)
print 'Begin to upload file to %s' %ip
print datetime.datetime.now()
try:
sftp.put(local_file,remote_file)
except IOError,e:
s='----ERR\n'
err_info="\033[1;32;40m%s %s %s\033[0m"%(e,ip,s)
f=file('sftp_err.log','a+')
f.write(err_info)
f.close()
print err_info
print datetime.datetime.now()
t.close()
阅读(1237) | 评论(0) | 转发(0) |