在 Solaris 中的 2 个管道中间打印 STDOUT(bash)
http://www.webdesignerdepot.com/rss.htm
我也有同样的问题。这个命令:
./somescript.sh > ../log/scriptlog.log
需要命令 go 的输出到 std out。但在脚本
命令 | mailx -s "Subject" [电子邮件受保护]
我想要做什么类似于:
命令|三通 > /dev/stdout | mailx -s "Subject" [email protected]
其中命令的输出转到 stdout(重定向到 ..log/scriptlog.log 文件),
也转到 stdin 以执行 mailx 命令。
有办法做到吗?
http://www.webdesignerdepot.com/rss.htm
I have the same issue. This command:
./somescript.sh > ../log/scriptlog.log
requires the output of a command go to std out. but inside the script
command | mailx -s "Subject" [email protected]
what I would like to do is something like :
command | tee > /dev/stdout | mailx -s "Subject" [email protected]
Where the output of the command goes to stdout( to be redirected into the ..log/scriptlog.log file )
and also into stdin for the mailx command.
Any way to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
tee
已发送到标准输出。tee
already sends to stdout.或者,使用进程替换:
or, using process substitution:
我将尝试进程替换。澄清一下,我有一个 cron'd shell 脚本。 cron 条目类似于:
/usr/script/myscript.sh > /usr/log/myscript.log
脚本内的 是类似于以下内容的行:
命令 | mailx -s“Subject”收件人
由于来自“command”的标准输出正在通过管道传输到mailx命令中,因此它确实出现在日志文件“myscript.log”中,但我希望它出现。
我尝试将其捕获到变量中,但换行似乎会以这种方式丢失。我可以使用临时文件,但我希望有更优雅的东西。
I'll try process substitution. To clarifily, I have a cron'd shell script . The cron entry is similar to:
/usr/script/myscript.sh > /usr/log/myscript.log
inside the script is a line similar to:
command | mailx -s "Subject" recipient
Since stdout from 'command' is being piped into the mailx command, it does appear in the log file 'myscript.log', but I want it to.
I tried capturing it into a variable but the line feeds appear to be lost that way. I could use a temporary file, but I was hoping for something more elegant.