What's a simple method to dump pipe input to a

2019-04-28 03:46发布

I'm looking for a little shell script that will take anything piped into it, and dump it to a file.. for email debugging purposes. Any ideas?

标签: linux pipe exim
11条回答
不美不萌又怎样
2楼-- · 2019-04-28 04:01

Use Procmail. Procmail is your friend. Procmail is made for this sort of thing.

查看更多
再贱就再见
3楼-- · 2019-04-28 04:01

You're not alone in needing something similar... in fact, someone wanted that functionality decades ago and developed tee :-)

Of course, you can redirect stdout directly to a file in any shell using the > character:

echo "hello, world!" > the-file.txt
查看更多
乱世女痞
4楼-- · 2019-04-28 04:06

The unix command tee does this.

man tee
查看更多
我欲成王,谁敢阻挡
5楼-- · 2019-04-28 04:09

The standard unix tool tee can do this. It copies input to output, while also logging it to a file.

查看更多
仙女界的扛把子
6楼-- · 2019-04-28 04:09

If exim or sendmail is what's writing into the pipe, then procmail is a good answer because it'll give you file locking/serialization and you can put it all in the same file.

If you just want to write into a file, then - tee > /tmp/log.$$ or - cat > /tmp/log.$$ might be good enough.

查看更多
爷、活的狠高调
7楼-- · 2019-04-28 04:12
cat > FILENAME
查看更多
登录 后发表回答