Python 实现两个服务器之间文件的上传方法
作者:lzbhnr 时间:2022-04-22 10:32:03
如下所示:
# coding: utf-8
import paramiko
import MySQLdb
def main(): connection=MySQLdb.connect(host='10.10.41.22',user='root',passwd='root',db='Trojan',port=3306)
cur=connection.cursor()
sql ='select count(*) from blacklist;'
cur.execute(sql)
count = cur.fetchone()[0]
print '一共有%s个应用需要上传'%(count)
sql = 'select path from blacklist;'
cur.execute(sql)
host = '10.10.41.22'
port = 22
username = 'remote2'
password = 'userforremote'
t = paramiko.Transport((host,port))
t.connect(username=username,password=password)
sftp = paramiko.SFTPClient.from_transport(t)
i=0
for path in cur.fetchall():
bendiPath = "/home/wcloud/apk_baseinfo_mounted_point/apk%s"%path
apkName =bendiPath.split("/")[-1]
servicePath = '/home/remote2/blacklist_wandoujia/%s'%apkName
print bendiPath
print servicePath
sftp.put(bendiPath,servicePath)
i=i+1
print '已经上传%s个应用,还有%d个应用没有上传'%(i,(count-i))
if __name__ == '__main__':
main()
来源:https://blog.csdn.net/lzbhnr/article/details/78499427
标签:Python,服务器,文件,上传
0
投稿
猜你喜欢
使用PDB简单调试Python程序简明指南
2022-07-27 21:03:28
什么是Dynamic HTML(Dhtml)
2010-03-16 12:40:00
CSS处理斜角导航条的一个例子
2007-08-27 12:38:00
Python3爬虫之urllib携带cookie爬取网页的方法
2022-07-01 14:19:02
Python网络爬虫信息提取mooc代码实例
2022-01-02 12:18:23
django框架用户权限中的session缓存到redis中的方法
2021-10-13 01:09:48
70+漂亮且极具亲和力的导航菜单设计推荐[译]
2009-02-23 13:15:00
轻松在线制作各种Logo标志
2008-05-26 12:54:00
MySQL 数据(字段)类型
2011-09-10 16:15:56
使用Python通过win32 COM实现Word文档的写入与保存方法
2021-03-16 04:09:27
使用Python实现一个栈判断括号是否平衡
2022-01-04 02:20:29
Django的CVB实例详解
2023-11-04 06:47:26
运行python脚本更改Windows背景
2022-06-11 05:36:54
Python+Opencv实现把图片、视频互转的示例
2022-03-24 23:07:38
WEB界面设计五种特征
2010-03-16 12:34:00
Python实现数通设备端口使用情况监控实例
2021-02-09 23:56:41
python speech模块的使用方法
2023-07-28 09:14:06
python中pandas对多列进行分组统计的实现
2022-06-25 03:50:03
如何在2003系统注册fso组件
2010-11-29 19:55:00
asp长文章分页显示思路
2007-08-23 13:54:00