inkedmn
03-14-2002, 06:10 PM
i coded this last night
#!/usr/bin/env python
import ftplib
try:
ftpconnect = ftplib.FTP()
server = 'ftp.python.org'
user = 'anonymous'
password = 'inkedmn@gmx.net'
ftpconnect.connect(server, 21)
print "connecting to %s" % server
ftpconnect.login(user, password)
print "logging in..."
welcome = ftpconnect.getwelcome()
print welcome
ftpconnect.cwd('pub/www.python.org')
print "changing to target directory..."
filesize = ftpconnect.size('robots.txt')
print "the file size is %i bytes" % filesize
print "getting text file..."
ftpconnect.retrbinary("RETR robots.txt", open('ftptest.txt', 'w').write)
ftpconnect.quit()
print "sending 'quit' message"
print "operation complete. thank you for your business"
except ftplib.error_perm, message:
print message
except ftplib.error_temp, message:
print message
except ftplib.error_reply, message:
print message
comments?
#!/usr/bin/env python
import ftplib
try:
ftpconnect = ftplib.FTP()
server = 'ftp.python.org'
user = 'anonymous'
password = 'inkedmn@gmx.net'
ftpconnect.connect(server, 21)
print "connecting to %s" % server
ftpconnect.login(user, password)
print "logging in..."
welcome = ftpconnect.getwelcome()
print welcome
ftpconnect.cwd('pub/www.python.org')
print "changing to target directory..."
filesize = ftpconnect.size('robots.txt')
print "the file size is %i bytes" % filesize
print "getting text file..."
ftpconnect.retrbinary("RETR robots.txt", open('ftptest.txt', 'w').write)
ftpconnect.quit()
print "sending 'quit' message"
print "operation complete. thank you for your business"
except ftplib.error_perm, message:
print message
except ftplib.error_temp, message:
print message
except ftplib.error_reply, message:
print message
comments?