最近工作中反复要用ftp工具,对某些固定的文件做下载,修改,再上传的操作,觉得很麻烦。想 编一个程序,可以自动执行ftp链接,对于某个设置好的路径和文件进行上传下载,想请教大家实现的方法,比如可以调用哪些API之类的?非常感谢
2条回答
- louy2 2013-12-02 02:36关注
可以使用perl,python等语言完成。
python可以使用ftplib。
import ftplib
session = ftplib.FTP('xxx.xxx.xxx.xxx','username','password')
session.cwd('dir')
file = open('tmp_ip_file','rb') # file to send
session.storbinary('STOR tmp_ip_file', file) # send the file
file.close() # close file and FTP
session.quit()本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报