T : R : G MOD를 사용하여 Perl System () 명령에 대한 진행 표시기가 필요합니다.
-
15-11-2019 - |
문제
perl 의 출력을 취하는 진행 표시기를 원한다.
system('make')
.
및 각 라인 출력에 대해 make 명령으로부터 stdout으로 출력하면 점 진행 표시기로서 점을 출력하고자합니다.불행히도, 저는 Term :: 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";}
제휴하지 않습니다 StackOverflow