axl163 has asked for the wisdom of the Perl Monks concerning the following question:
I need to execute a shell script program during which the progress indicator is running. How can I start the twirling baton in Perl and then suspend it when I need to execute a system call to run the shell script in Perl? Any advice would be greatly appreciated.#Twirling baton progress indicator sub twirling_baton { my $interval = 1; #Sleep time between twirls my $tcount = 0; my @baton = qw( | / - \ ); $| = 1; while ($interval) { $tcount++; print $baton[ $tcount % @baton ]; sleep ($interval); print "\b\b"; } }
my $pid; if ($pid = fork) { &twirling_baton(); waitpid($pid,0) } else { system("$program < $temp_file"); defined($pid) or die "fork: $!\n"; exit; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Executing a shell script with progress indicator
by BrowserUk (Patriarch) on Oct 11, 2005 at 21:41 UTC | |
Re: Executing a shell script with progress indicator
by ikegami (Patriarch) on Oct 11, 2005 at 18:40 UTC | |
Re: Executing a shell script with progress indicator
by ikegami (Patriarch) on Oct 11, 2005 at 20:51 UTC | |
by axl163 (Scribe) on Oct 11, 2005 at 21:15 UTC | |
Re: Executing a shell script with progress indicator
by Roy Johnson (Monsignor) on Oct 11, 2005 at 17:30 UTC | |
Re: Executing a shell script with progress indicator
by blazar (Canon) on Oct 11, 2005 at 17:36 UTC |