Re: FTP example going through a FTP Proxy



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
.



Relevant Pages

  • Re: FTP
    ... > Is is possible to use WinInet in vb.net 2003 to download files from an FTP server? ... The parsing and formatting was easy but the FTP stuff has me stuck. ... Has anyone used WinInet before for FTP? ...
    (microsoft.public.dotnet.languages.vb)
  • Re: unable to apt-get or wget
    ... Find a real news server. ... standard old fashioned 'ftp' client to connect to 'ibiblio.org'. ... able to download files via ftp either, ... Unless there were different rules set for ftp and http.. ...
    (alt.os.linux)
  • Re: FTP
    ... > Is is possible to use WinInet in vb.net 2003 to download files from an FTP ... > I can't get a list of the files on the server. ... Has anyone used WinInet ...
    (microsoft.public.dotnet.languages.vb)
  • FTP Folder error
    ... when im using Internet Explorer 6 as a FTP im unable to download files from the server my website is on, but I am able to upload fine? ... FTP Folder error, An error occured copying the selected items from the FTP Server ...
    (microsoft.public.windows.inetexplorer.ie6.ieak)
  • FTP example going through a FTP Proxy
    ... 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. ... The FTP proxy doesn't require username or password to ...
    (comp.lang.python)