tee不使用ssh运行外部脚本

时间:2018-03-13 19:02:02

标签: bash shell tee

我正在尝试记录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

我没有在log libs / debug-monitor-logs文件中获得任何内容 你能帮我看一下问题所在吗?

由于

1 个答案:

答案 0 :(得分:0)

看起来这样你只能在日志文件中写入“警告:终端无法访问或IP错误”

尝试这样的事情

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

而不是

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

(将整个表达式放在您想要管道输入三通的括号中)