2019独角兽企业重金招聘Python工程师标准>>>
'''
要把lftp指令嵌入到python程序里执行。需要用到lftp的-c 参数。我这里是要往ftp服务器上传文件,所以用到了put
'''
lftp --help
用法: lftp [OPTS] <site>
`lftp' 是在 rc 文件执行后 lftp 执行的第一个命令
-f <file> 执行文件中的命令后退出
-c <cmd> 执行命令后退出
--help 显示帮助信息后退出
--version 显示 lftp 版本后退出
其他的选项同 `open' 命令
-e <cmd> 在选择后执行命令
-u <user>[,<pass>] 使用指定的用户名/口令进行验证
-p <port> 连接指定的端口
<site> 主机名, URL 或书签的名字
一句话就可以执行了的lftp指令,在shell下测试过,ok的。
lftp -c "open -u user,pass ftpsite.com; put -O remote/dir/ /local/file.txt"