将 LFTP 结果输出到变量
Output LFTP result to variable
如何将 LFTP
结果保存到一个变量中,以便稍后在我的脚本中使用它。
这是我的基本命令:
lftp -c 'open -e "mirror /path/to/remote /path/to/local/" ftp://username:password@ftp.domain.com:21'
这显然是行不通的:
#!/bin/bash
output=""
lftp -c 'open -e "mirror /path/to/remote /path/to/local/" ftp://username:password@ftp.domain.com:21' > $output
echo "Test: " $output
编辑:
似乎问题是使用 lftp -c
没有创建任何输出。因此变量为空。所以问题是从 lftp
.
获取输出
使用Command Substitution
将命令的输出存储在变量中:
output=`lftp -c 'open -e "mirror /path/to/remote /path/to/local/" ftp://username:password@ftp.domain.com:21'`
echo "Test: ${output}"
如何将 LFTP
结果保存到一个变量中,以便稍后在我的脚本中使用它。
这是我的基本命令:
lftp -c 'open -e "mirror /path/to/remote /path/to/local/" ftp://username:password@ftp.domain.com:21'
这显然是行不通的:
#!/bin/bash
output=""
lftp -c 'open -e "mirror /path/to/remote /path/to/local/" ftp://username:password@ftp.domain.com:21' > $output
echo "Test: " $output
编辑:
似乎问题是使用 lftp -c
没有创建任何输出。因此变量为空。所以问题是从 lftp
.
使用Command Substitution
将命令的输出存储在变量中:
output=`lftp -c 'open -e "mirror /path/to/remote /path/to/local/" ftp://username:password@ftp.domain.com:21'`
echo "Test: ${output}"