Created
December 9, 2014 18:02
-
-
Save ironpythonbot/687973e8ceb85027f8b9 to your computer and use it in GitHub Desktop.
CodePlex Issue #32770 Plain Text Attachments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ftplib | |
import os | |
import sys | |
import traceback | |
import socket | |
socket.settimeout(20.0) | |
print "Logging in..." | |
ftp = ftplib.FTP() | |
host = "...." | |
port = 21 | |
login = "..." | |
password = "..." | |
some_directory = "/" | |
fullname = "test.txt" | |
ftp.connect(host, port) | |
print ftp.getwelcome() | |
try: | |
try: | |
ftp.login(login, password) | |
ftp.cwd(some_directory) | |
ftp.set_pasv(True) | |
# move to the desired upload directory | |
print "Currently in:", ftp.pwd() | |
name = os.path.split(fullname)[1] | |
print "Uploading...", name | |
f = open(fullname, "rb") | |
ftp.storbinary('STOR ' + name, f) | |
f.close() | |
print "OK" | |
print "Files:" | |
print ftp.retrlines('LIST') | |
finally: | |
print "Quitting..." | |
ftp.quit() | |
except: | |
traceback.print_exc() | |
raw_input("Press Enter...") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment