lftp 使用

环境信息

  • Centos 7

lftp 安装

yum install -y lftp

常见用法

查看帮助信息

$ lftp -h
Usage: lftp [OPTS] <site>
`lftp' is the first command executed by lftp after rc files
-f <file> execute commands from the file and exit
-c <cmd> execute the commands and exit
--help print this help and exit
--version print lftp version and exit
Other options are the same as in `open' command
-e <cmd> execute the command just after selecting
-u <user>[,<pass>] use the user/password for authentication
-p <port> use the port for connection
<site> host name, URL or bookmark name

登陆 FTP

命令格式

lftp ${USER}:${PASSWORD}@${FTPIP}:${FTPPORT}

上传文件

在一条 shell 命令中执行登陆、上传、退出操作

lftp -u ${USER},${PASSWORD} -p ${FTPPORT} ${FTPIP} -e "put /1.mp4 && exit"