加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 在一个Makefile规则里面重定向stdout和stderr

发布时间:2020-12-13 18:07:57 所属栏目:Linux 来源:网络整理
导读:我想将脚本的输出重定向到另一个程序.我通常会使用这两种形式: python test.py 21 | pyrg python test.py | pyrg 我的问题是它不能在一个makefile里面工作: [Makefile]test: python test.py 21 | pyrg [doesn't work] 我希望避免编写一个可以完成工作的脚
我想将脚本的输出重定向到另一个程序.我通常会使用这两种形式:
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

这是一个坏的解决方案,因为我没有得到猫的部分,以防测试失败(一切都在Makefile规则内)

解决方法

我偶然遇到同样的问题,对答案不满意.我有一个二进制TLBN,在测试用例example2.TLBN上失败.

这是我的make文件首先看到的.

make:
     ./TLBN example2.TLBN > ex2_output.txt

哪个失败,我正在期待和停止make进程的错误消息.

这是我的修复:

make:
    -./TLBN example2.TLBN > ex2_output.txt 2>&1

注意 – 在行的开头,告诉make忽略stderr的任何输出.

希望这有助于有类似问题的人.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读