1

I am trying to add a component to my application that grabs a file from an FTP location for processing. The FTP server accepts anonymous logins, but when using the code below, I receive a URLError 550 Access Denied. I have searched various locations for something similar, and have even added a password manager with no success. I continue to get the 550 access denied error.

Would appreciate any assistance.

Code Snippet:

import urllib2

url = "ftp://<Removed>com/outgoing/test/b10349cq.zip"  
response = urllib2.urlopen(url)  
zip_file = open('C:\\tmp\\file.zip', "w")  
zip_file.write(response.read())  
zip_file.close()  

Error:

Traceback (most recent call last):  
      File "C:\Documents and Settings\Administrator\Desktop\test.py", line 4, in <module>
    response = urllib2.urlopen(url)  
      File "C:\Python27\lib\urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)  
      File "C:\Python27\lib\urllib2.py", line 404, in open
    response = self._open(req, data)  
      File "C:\Python27\lib\urllib2.py", line 422, in _open
    '_open', req)  
      File "C:\Python27\lib\urllib2.py", line 382, in _call_chain
    result = func(*args)  
      File "C:\Python27\lib\urllib2.py", line 1394, in ftp_open
    fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout)  
      File "C:\Python27\lib\urllib2.py", line 1416, in connect_ftp
    persistent=False)  
      File "C:\Python27\lib\urllib.py", line 865, in __init__
    self.init()  
      File "C:\Python27\lib\urllib.py", line 874, in init
    self.ftp.cwd(dir)  
      File "C:\Python27\lib\ftplib.py", line 553, in cwd
    return self.voidcmd(cmd)  
      File "C:\Python27\lib\ftplib.py", line 249, in voidcmd
    return self.voidresp()  
      File "C:\Python27\lib\ftplib.py", line 224, in voidresp
    resp = self.getresp()  
      File "C:\Python27\lib\ftplib.py", line 219, in getresp
    raise error_perm, resp  
    URLError: urlopen error ftp error: 550 outgoing: Access is denied.
  • 1
    It seems like python browses the root directory first and then subsequentialy changes to the final directory. When you try to browse to "ftp://custftp2.nai.com/outgoing/" you will understand the error message – DIDoS Jan 03 '14 at 21:35
  • Is there any way to avoid browsing through the directories and just grab the file? The server is not set to allow that type of access which is why this seems to be failing. – user2012316 Jan 07 '14 at 19:38
  • Temporarily, I just hacked around it by utilizing lftp to pull the file and then to parse it. – user2012316 Jan 07 '14 at 23:10

0 Answers0