我想將腳本的輸出重定向到不同的程序。這是我通常會做使用這兩種形式:在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