2008年1月8日 星期二

[Python] Automatically upload a file

# This is an upload example for Python
# by Jing

from ftplib import FTP

# -------------------------- Your information ---------------------
host="140.113.x.x"
port=21;
user="jing"
passwd="xxxx"

# ftp command
ftp=FTP()
ftp.set_debuglevel(2)
ftp.connect(host,port)
ftp.login(user,passwd)
print ftp.getwelcome()

# ftp.cwd(UploadDir)   # swtch to the remote directory
ftp.storbinary('stor abc.txt',open('c:\\abc.txt'))  // upload command

ftp.set_debuglevel(0)
ftp.quit()

 

 

 

References

[1] FTP 可用指令 (raw Ftp command)

沒有留言:

張貼留言