Thread: ftplib Problem

    #1
  1. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154

    ftplib Problem


    I'm not sure why this is happening, but here's what I receive in the interpreter.
    Code:
    >>> ftp.retrbinary('RETR C:\\Documents and Settings\\Master\\Desktop\\monitor.xml', open('C:\\Documents and Settings\\Master\\Desktop\\monitor.xml', 'wb').write)
    Traceback (most recent call last):
      File "<pyshell#15>", line 1, in ?
        ftp.retrbinary('RETR C:\\Documents and Settings\\Master\\Desktop\\monitor.xml', open('C:\\Documents and Settings\\Master\\Desktop\\monitor.xml', 'wb').write)
      File "C:\PYTHON23\lib\ftplib.py", line 379, in retrbinary
        conn = self.transfercmd(cmd, rest)
      File "C:\PYTHON23\lib\ftplib.py", line 345, in transfercmd
        return self.ntransfercmd(cmd, rest)[0]
      File "C:\PYTHON23\lib\ftplib.py", line 327, in ntransfercmd
        resp = self.sendcmd(cmd)
      File "C:\PYTHON23\lib\ftplib.py", line 241, in sendcmd
        return self.getresp()
      File "C:\PYTHON23\lib\ftplib.py", line 214, in getresp
        raise error_perm, resp
    error_perm: 550 Prohibited file name: C:\Documents and Settings\Master\Desktop\monitor.xml
    >>>
    Am I maybe typing in the wrong stuff to send the file? Here is what ftp equals.
    Code:
    ftp = FTP('ftp.elitenerds.com', 'downloads@elitenerds.com', 'passwordhere', 'downloads')
    This connects fine (that's not my password of course), the only problem is uploading a file.
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Ok well it looks to me somewhat like you don't have permission to upload the file to server. Can you normally upload?

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Well, when I'm using Core FTP I can upload these files without a problem. I also tried using ftplib to upload a simple text document, it still wouldn't work. What can cause me to not have permission to upload?
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    You're calling it wrongly me thinks. The first parameter to retrbinary should be the path of the file on the FTP server.
    ftp.retrbinary('RETR monitor.xml', open('c:\foo\monitor.xml').write)
    or even:
    ftp.retrbinary('RETR /path/to/monitor.xml', open('c:\foo\monitor.xml').write)
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  8. #5
  9. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    I'm still having problems. Now I have the following:
    Code:
    >>> ftp.retrbinary('RETR monitor.xml', open('c:\documents and settings\master\desktop\monitor.xml').write)
    Traceback (most recent call last):
      File "<pyshell#32>", line 1, in ?
        ftp.retrbinary('RETR monitor.xml', open('c:\documents and settings\master\desktop\monitor.xml').write)
      File "C:\PYTHON23\lib\ftplib.py", line 379, in retrbinary
        conn = self.transfercmd(cmd, rest)
      File "C:\PYTHON23\lib\ftplib.py", line 345, in transfercmd
        return self.ntransfercmd(cmd, rest)[0]
      File "C:\PYTHON23\lib\ftplib.py", line 327, in ntransfercmd
        resp = self.sendcmd(cmd)
      File "C:\PYTHON23\lib\ftplib.py", line 241, in sendcmd
        return self.getresp()
      File "C:\PYTHON23\lib\ftplib.py", line 214, in getresp
        raise error_perm, resp
    error_perm: 550 Can't open monitor.xml: No such file or directory
    >>>
    I know the file exists too. Python won't let me upload ANY file, no matter what file I attempt to send, I receive the same error. And I know that that is the correct file location to.
  10. #6
  11. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    Wait a sec. Did you mean send a file? retrbinary *retrieves* a file. You need storbinary to send a file over.
    ftp.storbinary('STOR monitor.xml', open('c:\foo\monitor.xml'))
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  12. #7
  13. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Omg, that was quite simple. Thanks.

IMN logo majestic logo threadwatch logo seochat tools logo