tee 无法使用 ssh 运行 外部脚本

tee not working with ssh running an external script

我正在尝试记录 ssh 会话期间发生的一切,同时在 shell 上显示输出。

sshpass -p "password" ssh -tt -o ConnectTimeout=10 -oStrictHostKeyChecking=no username@"$terminal" 'bash -s' < libs/debug-mon.lib "$function" | grep -E '^INFO:|^WARNING:' || echo "WARNING: Terminal not reacheable or wrong IP" | tee -a libs/debug-monitor-logs

我在日志 libs/debug-monitor-logs 文件中没有得到任何信息 能帮我看看问题出在哪里吗?

谢谢

看起来你唯一要写入日志文件的是 "WARNING: Terminal not reacheable or wrong IP"

尝试这样的事情

(command-that-might-fail || echo error message) | tee -a log-file

而不是

commant-that-might-fail || echo error message | tee -a log-file

(将要传递到 tee 中的整个表达式放在括号中)