#!/usr/bin/python2.7 # -*- coding: utf-8 -*- #add by tanglin@2012.6.14 import os import re import paramiko import time def sftp_down_f(server_path,local_path): t=paramiko.Transport(('172.17.242.82',22)) t.connect(username='root',password='Macro3') sftp=paramiko.SFTPClient.from_transport(t) sftp.get(server_path,local_path) while True: sftp_down_f("/var/log/messages","D:\messages") time.sleep(2)
上传文件:sftp.put(local_path,server_path)