Python 实现两个服务器之间文件的上传方法
2019-03-28 10:58
429 查看
如下所示:
# 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()
以上这篇Python 实现两个服务器之间文件的上传方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
相关文章推荐
- Python如何实现两个服务器之间文件的上传
- 和我一起使用Python的bottle来实现文件的上传和下载(使用post方法)
- Ubuntu,两个服务器之间 复制文件方法(还包括一些基本的数据处理的部分)
- OkHttp学习(3)-->>同步、异步之上传文件至服务器(重写RequestBody方法,实现上传进度接口回调)
- python实现从ftp服务器下载文件的方法
- python实现从ftp服务器下载文件的方法
- .NET实现文件跨服务器上传下载的方法
- linux下远程服务器批量执行命令及SFTP上传文件 -- python实现
- Python实现简易文件服务器 包含上传下载删除新建目录功能
- Python实现计算两个时间之间相差天数的方法
- python 实现统计ftp服务器指定目录下文件夹数目、文件数目及所有文件大小 本次主要为满足应用方核对上传到ftp服务器的文件是否缺漏。 主要要求:指定目录下,文件夹数目/文件数目/所有文件大小
- Python实现在matplotlib中两个坐标轴之间画一条直线光标的方法
- Python实现在matplotlib中两个坐标轴之间画一条直线光标的方法
- python实现支持目录FTP上传下载文件的方法
- python实现支持目录FTP上传下载文件的方法
- .NET将文件上传到网络共享服务器的方法(已验证实现)
- NodeJS与HTML5相结合实现拖拽多个文件上传到服务器的实现方法
- java实现将文件上传到ftp服务器的方法
- 通过python模块实现服务器和本地机器之间快速拷贝文件
- phpcms实现图文分离,文件上传到远程服务器的方法