Bash Curl下载并删除文件ftp

Bash Curl下载并删除文件ftp,bash,curl,Bash,Curl,我需要从ftp服务器下载文件,并在传输后将其删除(在远程服务器上) 它可能在一个命令行中 curl ftp://host/testfile.txt -X 'GET testfile.txt' --user user:password -o local.txt curl ftp://host/testfile.txt -X 'DELE testfile.txt' --user user:password 谢谢我建议为您的FTP命令创建一个脚本,并将它们导入内置的FTP客户端。下面是一个在我的机器

我需要从ftp服务器下载文件,并在传输后将其删除(在远程服务器上) 它可能在一个命令行中

curl ftp://host/testfile.txt -X 'GET testfile.txt' --user user:password -o local.txt
curl ftp://host/testfile.txt -X 'DELE testfile.txt' --user user:password

谢谢

我建议为您的FTP命令创建一个脚本,并将它们导入内置的
FTP
客户端。下面是一个在我的机器上工作的示例(将
test.ftpscript
中的
ls
命令替换为
GET/DEL
命令):

[user@host~]cat>test.ftpscript
匿名用户anonymous@gmail.com
ls
再见
[user@host~]ftp-inv ftp.swfwmd.state.fl.us酒吧
drwxr-xr-x 30 0 4096 Dec 04 15:26 pvt
226目录发送确定。
再见。

[user@host~]

是的,可以在单个命令中执行此操作:

curl -Q '-DELE testfile.txt' --user user:password -o local.txt ftp://host/testfile.txt 
从手册页:

-Q, --quote
       (FTP SFTP) Send an arbitrary command to the remote FTP  or  SFTP
       server.  Quote commands are sent BEFORE the transfer takes place
       (just after the initial PWD command in an FTP  transfer,  to  be
       exact). To make commands take place after a successful transfer,
       prefix them with a dash '-'.  To make  commands  be  sent  after
       curl has changed the working directory, just before the transfer
       command(s), prefix the command with a '+'  (this  is  only  sup‐
       ported for FTP). You may specify any number of commands.

这样做吗?:下载命令;delete command‘它可能在一个命令行中?’当然,试试看:)我指的是只连接一次而不是多个连接的东西您可以试试ftp命令。