Thread: FTP Problems

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    MA, USA
    Posts
    64
    Rep Power
    14

    Angry FTP Problems


    I'm having trouble with the ftplib module in Python 2.0

    It was working yesterday but today it is giving me trouble. I'll post the traceback output below.

    Code:
    Traceback (most recent call last):
      File "c:\python20\pythonwin\pywin\framework\scriptutils.py", line 394, in ImportFile
        exec codeObj in __main__.__dict__
      File "<auto import>", line 1, in ?
      File "C:\Documents and Settings\All Users\Desktop\ftp_test.py", line 13, in ?
        ftp = ftplib.FTP("webstage.intra.lifespan.org")
    AttributeError: FTP
    Any thoughts?

    Thanks,
    Chris
    "Once begun, half done." - EP
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    266
    Rep Power
    14
    If you haven't changed your Python script from the night before I would say it is something outside of your Python script that has changed.

    I can't be much more helpful than that without seeing the code.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    MA, USA
    Posts
    64
    Rep Power
    14

    Code


    Good point - Here's the code.
    Code:
    import ftplib
    import os
    import re
    
    print "\nBegining Transfer..."
    
    reportDirectory = "C:\Program Files\Analog\Reports"
    ftpTarget = "webstage.intra.lifespan.org"
    ftpDirectory = "webreports/testing"
    ftpUser = "anonymous"
    ftpPass = "anon@lifespan.org"
    
    ftp = ftplib.FTP("webstage.intra.lifespan.org")
    ftp.login(ftpUser,ftpPass)
    ftp.cwd(ftpDirectory)
    print "\n" + ftp.getresp()
    #print os.getcwd()
    for file in os.listdir(reportDirectory):
    	print "\n" + file
    	if re.match("\w+\d{6}\.html",file):
    		ftp.storbinary("STOR" + file, open(file, "rb"), 1024)
    		print "\n" + ftp.getresp()
    		
    print "\nDone Transfer"
    
    print ftp.dir()
    
    ftp.quit()
    Last edited by xangelusx; July 25th, 2001 at 02:39 PM.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    266
    Rep Power
    14
    Sorry its taken me so long to get back to you.

    I ran your code up until the point that I logged in to a server. One problem I found is that the address could not be found which generated an error. I put in my own ftp address with l/p and it worked fine.

    I only ran the code on the interactive command line until this point.

    print "\n" + ftp.getresp()

    Hope this helps.

    E.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    MA, USA
    Posts
    64
    Rep Power
    14
    Hi, and thanks for writing back again.

    I can't believe I didn't catch this before but the problem was because I was trying to connect to our intranet server from our extranet server which exists on the outside of our firwall. DUH!

    Thanks again for checking into it, though.

    Chris Bloom

IMN logo majestic logo threadwatch logo seochat tools logo