What's wrong with this program

jedi jedi at ccrypt.net
Tue Jul 3 12:06:18 EDT 2001


Try it like this:

import string, os
import ftplib
print string.join(os.listdir('d:\programsPerl'),',')
ftp = FTP('144.144.144.144') #specify host
ftp.connect # defaults to port 21, check docs for further options
ftp.login(user='Goofy',passwd='elmer',acct='fudd')   # user info
ftp.cwd('/usr2/ecadtesting/tarbackups/')
ftp.retrlines('LIST')  # list directory contents
ftp.quit()

that's on first glance at the docs, but it should work.

On Tue, 3 Jul 2001, Kemp Randy-W18971 wrote:

> 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
> >>>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>





More information about the Python-list mailing list