[Tutor] glob paramiko
Matt Herzog
msh at blisses.org
Fri May 8 19:04:59 CEST 2009
Hey All.
All I need to do in this script is scp or sftp a bunch of files to a remote server. This script will run from a cron job eventually.
For whatever reason, paramiko can't cope with a list.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/Users/msh/<ipython console> in <module>()
AttributeError: 'NoneType' object has no attribute 'put'
In [18]: type localpath
-------> type(localpath)
Out[18]: <type 'list'>
In [19]: for each in localpath
------------------------------------------------------------
------ script begins ------------
import paramiko
import glob
import os
paramiko.util.log_to_file('/tmp/paramiko.log')
host = "sftp.okcomputer.yo"
port = 22
transport = paramiko.Transport((host, port))
password = "T0pS3kr1t!"
username = "schizznits"
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
os.chdir("/home/fatcat/")
filepath = '/'
localpath = glob.glob("*.tab")
sftp.put(localpath, filepath)
sftp.close()
transport.close()
--- script ends ------
--
I fear you speak upon the rack,
Where men enforced do speak anything.
- William Shakespeare
More information about the Tutor
mailing list