Re: FTP example going through a FTP Proxy
- From: jakecjacobson <jakecjacobson@xxxxxxxxx>
- Date: Wed, 7 Jan 2009 11:11:27 -0800 (PST)
On Jan 7, 12:32 pm, jakecjacobson <jakecjacob...@xxxxxxxxx> wrote:
Hi,
I need to write a simple Python script that I can connect to a FTP
server and download files from the server to my local box. I am
required to go through a FTP Proxy and I don't see any examples on how
to do this. The FTP proxy doesn't require username or password to
connect but the FTP server that I am connecting to does.
Any examples on how to do this would be greatly appreciated. I am
limited to using Python version 2.4.3 on a Linux box.
This is what I have tried so far,
import urllib
proxies = {'ftp':'ftp://proxy_server:21'}
ftp_server = 'ftp.somecompany.com'
ftp_port='21'
username = 'aaaa'
password = 'secretPW'
ftp_string='ftp://' + username + '@' + password + ftp_server + ':' +
ftp_port
data = urllib.urlopen(ftp_string, proxies=proxies)
data=urllib.urlopen(req).read()
print data
I get the following error:
Traceback (most recent call last):
File "./ftptest.py", line 22, in ?
data = urllib.urlopen(ftp_server, proxies=proxies)
File "/usr/lib/python2.4/urllib.py", line 82, in urlopen
return opener.open(url)
File "/usr/lib/python2.4/urllib.py", line 190, in open
return getattr(self, name)(url)
File "/usr/lib/python2.4/urllib.py", line 470, in open_ftp
host, path = splithost(url)
File "/usr/lib/python2.4/urllib.py", line 949, in splithost
match = _hostprog.match(url)
TypeError: expected string or buffer
.
- Follow-Ups:
- Re: FTP example going through a FTP Proxy
- From: jakecjacobson
- Re: FTP example going through a FTP Proxy
- References:
- FTP example going through a FTP Proxy
- From: jakecjacobson
- FTP example going through a FTP Proxy
- Prev by Date: Re: How to get millisec/fractional seconds out of a time object ?
- Next by Date: Re: [Mechanize.ClientForm] double reading from urllib2.urlopen
- Previous by thread: FTP example going through a FTP Proxy
- Next by thread: Re: FTP example going through a FTP Proxy
- Index(es):
Relevant Pages
|