当尝试将所有输出记录到FTP会话的变量中时,该变量为空白。我尝试了以下所有变体,结果都相同:
OUT=$(ftp -in $FTP_HOST << END_SCRIPT
quote USER $FTP_USER
quote PASS $FTP_PASS
binary
cd /home/ftp/files
get test.txt
quit
END_SCRIPT
)
echo $OUT
变化#2:
OUT=$(ftp -in $FTP_HOST 2>&1 << END_SCRIPT
quote USER $FTP_USER
quote PASS $FTP_PASS
binary
cd /home/ftp/files
get test.txt
quit
END_SCRIPT
)
echo $OUT
还有其他地方的输出要写入吗?
答案 0 :(得分:0)
管道| tee
适用于我的用例