【问题标题】:Redirecting stdout and stderr output to a file using system command doesn't work in perl [duplicate]使用系统命令将stdout和stderr输出重定向到文件在perl中不起作用[重复]
【发布时间】:2014-08-05 07:50:30
【问题描述】:

当我尝试将命令的 stdout 和 stderr 输出重定向到文件时。没有任何东西被写入文件。这是在 Perl 脚本中。我希望将命令的 stdout 和 stderr 输出重定向到文件。我写的代码是这样的:

system("sudo rm a.txt &>> output.txt");

文件output.txt 根本不包含任何内容。有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: perl bash perl-module


    【解决方案1】:
    system("sudo rm a.txt >> output.txt 2>&1")
    

    【讨论】:

      猜你喜欢
      • 2014-07-22
      • 2017-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-14
      • 1970-01-01
      • 2011-11-23
      相关资源
      最近更新 更多