T:R:G MODを使用してPerl System()コマンドの進捗インジケータが必要

StackOverflow https://stackoverflow.com/questions/6052345

質問

Perl の出力をとる進捗インジケータが欲しい

   system('make')
.

および各行の出力は、makeコマンドからSTDOUTに出力されます.Progessインジケータとしてドットを出力したいです。残念ながら、:: readline :: gnu perl mod。

makeコマンドが実行されているように、Stdoutをキャプチャして回線をカウントするにどのようにリダイレクトしますか?

役に立ちましたか?

解決

#!/usr/bin/perl

my $command = "make";

open (my $cmd, "$command |");
while(<$cmd>){
  print ".";
}
print "\n";

他のヒント

make >& >(while read f; do echo -n .; done; echo)

Obviously this is a shell solution, but a dot as a progress indicator is a dot.

You could of course stick a tee in there to save a copy of the make to file in case of problems.

Since you didn't seem to like (neither upvoted or accepted) the shell solution for some unexplained reason, here is a pure perl one:

if (open(X,"make|")) { local($|)=1; while(<X>) { print "."; } close(X); print "\n";}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top