FTP upload issue
davidj411
davidj411 at gmail.com
Thu May 15 16:25:33 EDT 2008
I am having difficulty uploading a text file using Python 2.5 on MAC
OSX.
SCRIPT
filename='/tmp/mac.info2.txt'
fh=open(filename,'w')
fh.write('yes, i have a mac but don't hold that against me - just
example data')
fh.close()
from ftplib import FTP
'host, username, and password are string variables that have already
been defined.
ftp = FTP(host)
ftp.login(username,password)
'so far, logged in, all is well , error is on next line.
ftp.storlines("STOR" + filename, file(filename))
ftp.quit()
What am i doing wrong? the file DOES exist, the path is correct, and
the file was closed after being written. file(filename) should open
it again for the upload?
http://www.python.org/doc/lib/ftp-objects.html says that the command
should be an appropriate "STOR" command: "STOR filename". file is an
open file object which is read...
ERROR
File "mac.inventory.py", line 44, in <module>
ftp.storlines("STOR " + filename, file(filename))
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/ftplib.py", line 437, in storlines
conn = self.transfercmd(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/ftplib.py", line 356, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/ftplib.py", line 327, in ntransfercmd
resp = self.sendcmd(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/ftplib.py", line 241, in sendcmd
return self.getresp()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/ftplib.py", line 216, in getresp
raise error_perm, resp
ftplib.error_perm: 550 /tmp/mac.info2.txt: The system cannot find the
path specified.
More information about the Python-list
mailing list