[Tutor] sftp get single file
Matt Herzog
msh at blisses.org
Fri Jul 17 17:08:43 CEST 2009
Hello All.
I need to use paramiko to sftp get a single file from a remote server.
The remote file's base name will be today's date (%Y%m%d) dot tab.
I need help joining the today with the .tab extension. Do I need globbing?
example: 20090716.tab
#!/usr/bin/env python
import paramiko
import glob
import os
import time
hostname = 'sftp.booboo.com'
port = 22
username = 'booboo'
password = '07N4219?'
# glob_pattern='*.tab'
today = time.strftime("%Y%m%d")
remotepath = today.tab
localpath = '/home/data/text'
if __name__ == "__main__":
t = paramiko.Transport((hostname, port))
t.connect(username=username, password=password)
sftp = paramiko.SFTPClient.from_transport(t)
sftp.get(remotepath, localpath)
t.close()
--
I fear you speak upon the rack,
Where men enforced do speak anything.
- William Shakespeare
More information about the Tutor
mailing list