[Tutor] FTP from mainframe

Christian Witts cwitts at compuscan.co.za
Fri Jul 30 07:53:28 CEST 2010


On 29/07/2010 18:34, Steve Bricker wrote:
> This is my first attempt to FTP a file from a mainframe.  The code:
>
> import ftplib
> session = ftplib.FTP('company.lan.com','userid','passwd')
> myfile = open('PC.filename','w')
> session.retrlines("RETR 'mainframe.filename'", myfile)
> myfile.close()
> session.quit()
>
> The resulting error is:
>
> Traceback (most recent call last):
>   File "ftp_from_mf.py", line 5, in <module>
>     session.retrlines("RETR 'mainframe.filename'", myfile)
>   File "c:\python26\lib\ftplib.py", line 428, in retrlines
>     callback(line)
> TypeError: 'file' object is not callable
>
> Not sure what I'm missing.
>
> Steve Bricker
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>    

When I'm retrieving items I use retrbinary for eg.

from ftplib import FTP

ftp = FTP(url, username, password)
for filename in ftp.nlst(''):
     ftp.retrbinary('RETR %s' % filename, open(filename, 'wb').write)
     ftp.delete(filename)

ftp.close()

I hope that helps.

-- 
Kind Regards,
Christian Witts
Business Intelligence

C o m p u s c a n | Confidence in Credit

Telephone: +27 21 888 6000
National Cell Centre: 0861 51 41 31
Fax: +27 21 413 2424
E-mail: cwitts at compuscan.co.za

NOTE:  This e-mail (including attachments )is subject to the disclaimer published at: http://www.compuscan.co.za/live/content.php?Item_ID=494.
If you cannot access the disclaimer, request it from email.disclaimer at compuscan.co.za or 0861 514131.

National Credit Regulator Credit Bureau Registration No. NCRCB6




More information about the Tutor mailing list