[Tutor] FTP from mainframe
Bill Campbell
bill at celestial.net
Thu Jul 29 20:15:23 CEST 2010
On Thu, Jul 29, 2010, bob gailer wrote:
>
> On 7/29/2010 12:34 PM, Steve Bricker wrote:
>
> This is my first attempt to FTP a file from a mainframe. The code:
> import ftplib
The easiest way I've found to get a file via ftp in python is to
user urllib, not ftplib. Something like this (add error checking).
import urllib, os
fname='something.pdf'
url = 'ftp://%s@%s:%s/%s' % ('john', 'secret', 'example.com', fname)
# f will have a temporary file name, and h the headers
(f, h) = urllib.urlretrieve(url)
os.rename(f, fname)
Of course this works for http by simply changing the url.
Bill
--
INTERNET: bill at celestial.com Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
Voice: (206) 236-1676 Mercer Island, WA 98040-0820
Fax: (206) 232-9186 Skype: jwccsllc (206) 855-5792
If you want government to intervene domestically, you're a liberal. If you
want government to intervene overseas, you're a conservative. If you want
government to intervene everywhere, you're a moderate. If you don't want
government to intervene anywhere, you're an extremist -- Joseph Sobran
More information about the Tutor
mailing list