ftp

Binu K S binux.lists at gmail.com
Thu Dec 16 04:43:08 CET 2004


Try retrbinary instead of retrlines in the original script (the one
without write('\n')).
retrlines fetches the file in ASCII mode and that must be altering the
line terminations.

On 15 Dec 2004 15:49:31 -0800, hawkmoon269 <rson at new.rr.com> wrote:
> I would like to write a small ftp script that I could use in place of
> DOS.  So far I have this --
> 
> from ftplib import FTP
> 
> server = 'xxx'
> username = 'xxx'
> password = 'xxx'
> file = 'xxx'
> 
> ftp = FTP(server)
> ftp.login(username, password)
> ftp.retrlines('RETR ' + file, open('C:\My Documents\' + file,
> 'w').write
> 
> but this just writes the source files contents into a giant string in
> the output file.  The source file is comma-delimited with a
> fixed-length of 80 chars per line.  I need the same format for the
> output file.  I've tried this --
> 
> ftp.retrlines('RETR ' + file, open('C:\My Documents\' + file,
> 'w').write('\n')
> 
> and that gives the correct output format...but it writes the output to
> the IDE interpreter command line and not the file.  What am I doing
> wrong?
> 
> hawk
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list