当试图将所有输出记录到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
是否有其他地方会写入输出?
管道| tee
适用于我的用例