我有一个Perl脚本,说“process_output.pl”这是在下列情况下使用:行缓冲读取在Perl
long_running_command | “process_output.pl”
的process_output脚本,需要像Unix的“三通”命令,因为它得到生成的转储“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 needed
use FileHandle; STDOUT->autoflush(1);
stdbuf -oL -eL long_running_command | "process_output.pl"
有关如何继续的任何指示 进一步。
感谢 AB