lftp:登录,将文件放在远程目录中,然后在单个命令中退出:正确的引用帮助


17

我想用一次lftp -c完成一个整个会话(因为稍后我将从脚本中启动它),-e但我设法做到了,但是ofc却让我参与了我不想使用的交互式会话。

手动状态

-c commands
          Execute the given commands and exit. Commands can be separated with a semicolon,  `&&'
          or  `||'.  Remember to quote the commands argument properly in the shell.  This option
          must be used alone without other arguments.

但是我不明白我应该如何正确地将命令/交互引用和字符串在一起。

lftp -e "put -O remote/dir/ /local/file.txt" -u user,pass ftpsite.com 效果很好。但是我想在执行命令后退出;

lftp -c "open -u user,pass ftpsite.com" || put -O "remote/dir/ /local/file.txt" 只是对我大喊大叫,或者实际上我尝试过的任何报价组合(||&&无论如何)


只需添加; quit或; bye :)
meso_2600 2014年

Answers:


28
$ lftp -c "open -u user,pass ftpsite.com; put -O remote/dir/ /local/file.txt" 

应该这样做。

如果这不起作用,请尝试添加/etc/lftp.conf以下行:

set ftp:ssl-protect-data true
set ftp:ssl-force true
set ftp:ssl-auth TLS
set ssl:verify-certificate no

2
无论如何,如果密码中包含字符,是否可以使此工作正常进行?' " : ;
Pete

我绊倒了,因为在第一次逗号之后我有一个空格,一旦我发现它很好用就可以了
patrick '18

10

lftp -e "put -O remote/dir/ /local/file.txt; bye" -u user,pass ftpsite.com


1

lftp -e "put -O remote/dir/ /local/file.txt; bye" ftp.yourhost.com

并将您的凭据放在〜/ .netrc下,例如

machine ftp.yourhost.com login your_username password your_password

将密码放在cli中绝对是不行的,因为在上传过程中使用ps -aux时,甚至可以读取密码。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.