我想将脚本的输出重定向到不同的程序。这是我通常会做使用这两种形式:在Makefile规则中重定向标准输出和stderr
python test.py 2>&1 | pyrg
python test.py |& pyrg
我的问题是,它并没有从一个makefile内工作:
[Makefile]
test:
python test.py 2>&1 | pyrg [doesn't work]
我想避免编写一个脚本文件,它做的工作。
编辑:
这似乎是一个pyrg
问题:
python test.py 2>&1 | tee test.out // Writes to the file both stderr and stdout
cat test.out | pyrg // Works fine!
python test.py 2>&1 | pyrg // pyrg behaves as if it got no input
这对我来说是一个坏的解决方案,因为我从来没有到cat
部位在试验失败的情况下(一切在Makefile规则里面)
这应该工作。 'make'将整行传递给'/ bin/sh'来解释,所以任何这个shell(不需要是你的用户shell)都可以理解。 – 2012-08-01 08:26:11
究竟是如何不起作用?尝试在makefile中的某处设置'export SHELL:=/bin/bash'。 – 2012-08-01 08:34:26
第二个命令运行,就好像它没有收到任何来自'stdin'的输入。它实际上在第一个之前运行。使用'||'而不是'|'来维护顺序,但又一次'pyrg'没有得到输入。 – Xyand 2012-08-01 08:51:09