【发布时间】:2014-02-22 15:55:36
【问题描述】:
我有一个 perl 脚本,比如“process_output.pl”,它在以下上下文中使用:
long_running_command | “process_output.pl”
process_output 脚本需要类似于 unix “tee”命令,它在生成时将“long_running_command”的输出转储到终端,此外还将输出捕获到文本文件,并在“long_running_command”的末尾",以文本文件作为输入分叉另一个进程。
我目前看到的行为是,“long_running_command”的输出仅在完成时才转储到终端,而不是在生成时转储输出。我需要做一些特别的事情来解决这个问题吗?
根据我在其他一些 stackexchange 帖子中的阅读,我在“process_output.pl”中尝试了以下内容,但没有太多帮助:
select(STDOUT); $| =1;select(STDIN); $| =1; # Not sure even if this is neededuse FileHandle; STDOUT->autoflush(1);stdbuf -oL -eL long_running_command | "process_output.pl"
关于如何进一步进行的任何指示。
谢谢 乙
【问题讨论】: