Need a progress indicator for a Perl system() command using T:R:G modから素敵な進行状況インジケーターがあります
open(my $cmd, '-|', "$command $flags_args 2>/dev/null")
or print "\nAttention: Command $command $flags_args failed $!"
and return 1;
while (<$cmd>)
{
$percentage = ($cntr/$lines) * 100;
$percentage = 100 if $percentage > 100;
printf("Progress: %3d%%\r", $percentage);
$cntr++;
}
close($cmd);
ここで、コマンド出力の STDOUT と STDERR をログに記録したいと思います。私はパイプ出力にあまり慣れていないので、追加してみました:
print $LOG $cmd
と
print $LOG Dumper(\$cmd)
while ループの終了前。それは動かなかった。最初の出力
GLOB(0x11df7a0)GLOB(0x11df7a0)GLOB(0x11df7a0)
二番目
$VAR1 = \\*{'::$cmd'};
$VAR1 = \\*{'::$cmd'};
$VAR1 = \\*{'::$cmd'};
パイプされた $cmd から出力を取得する方法を知っている人はいますか? $command = make コマンドの例
Making all in src
make[1]: Entering directory `/tmp'
Making all in include
make[2]: Entering directory '/tmp/2'
...