如何在lftp中运行shell命令进行文件传输?

时间:2020-10-15 11:49:56

标签: shell sftp file-transfer lftp

我需要从其中包含子目录的远程目录中复制一些文件。我正在使用lftp来执行此操作,但是其中的shell命令不起作用。有没有解决方法?请参见下面的代码。任何帮助都非常感谢你们!

lftp -u $USER,$PASS sftp://$HOST <<EOF 2>&1

#find file file_name with absolutepath from REMOTE_DIR which lies in any of its subdirectories
filefound=`find "${REMOTE_DIR}"`-name "{$file_name}"`

#Get the absolutepath for subdirectory where the file resides
dir_loc=`dirname "${filefound}"`

lcd ${LOCAL_DIR}
cd ${dir_loc}
get ${file_name}
bye
EOF

我得到的错误是: filefound:找不到命令 dir_loc:找不到命令

1 个答案:

答案 0 :(得分:0)

这是一个概念上的误解。

您不能使用SFTP客户端运行shell命令。要运行Shell命令,请使用SSH客户端。

相关问题