July 25th, 2001, 10:34 AM
-
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
July 25th, 2001, 01:20 PM
-
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.
July 25th, 2001, 01:25 PM
-
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 01:39 PM.
July 30th, 2001, 05:35 PM
-
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.
July 31st, 2001, 07:41 AM
-
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