What's wrong with this program

Kemp Randy-W18971 Randy.L.Kemp at motorola.com
Tue Jul 3 11:50:37 EDT 2001


I am writing a short Python program to FTP data in my windows directory to a windows machine.  Here is the program (with IP, name., and password changed to protect the innocent, along with the trace.  What do I need to modify to ftp all the files in my particular windows directory to a directory on a Unix machine, using a user account with name and password provided?

import string, os 
from ftplib import FTP
print string.join(os.listdir('d:\programsPerl'),',')
ftp = FTP('144.144.144.144',21) #connect to host, default port
ftp.login(user='Goofy',passwd='elmer',acct='fudd')   # default, i.e.: user name, passwd hostname
ftp.cwd('/usr2/ecadtesting/tarbackups/')
ftp.retrlines('LIST')  # list directory contents
ftp.quit()    

Here is the trace

raceback (most recent call last):
  File "D:\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript
    exec codeObject in __main__.__dict__
  File "D:\programsPython\ftpdata.py", line 4, in ?
    ftp = FTP('144.144.144.144',21) #connect to host, default port
  File "D:\Python20\lib\ftplib.py", line 108, in __init__
    if user: resp = self.login(user, passwd, acct)
  File "D:\Python20\lib\ftplib.py", line 318, in login
    resp = self.sendcmd('USER ' + user)
TypeError: cannot add type "int" to string
>>> 




More information about the Python-list mailing list