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

如何在lftp中运行shell命令来进行文件传输?,shell,sftp,file-transfer,lftp,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

我需要从一个有子目录的远程目录复制几个文件。我正在使用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

lftp-u$USER,$PASS-sftp://$HOST这是一个概念上的误解

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