Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a script that I run from NT command line. Sometimes it takes 15 minutes to run. Anyway I can make a "heartbeat" or some ticks ( like dots moving left to rigth like this .........) to show that the script is still alive. Or something to show that there is activity and the script is still running.
  • Comment on Script heartbeat to show it is still running

Replies are listed 'Best First'.
Re: Script heartbeat to show it is still running
by belg4mit (Prior) on Jul 03, 2003 at 21:03 UTC
    This would likely be easier with POE, or if you fork and the child does the work letting the parent check the child's status and update your display... except you're on NT. Some status displays you might be interested in include Acme::Spinner, Term::Twiddle, Term::StatusBar & wget style progress bar

    --
    I'm not belgian but I play one on TV.

        Well sure, I suppose, but I doubt that's what it was intended for. ++ for reminding me of it though (I never could thiknk of a use for it myself. at least not one I wouldn't end up rolling my own for)

        --
        I'm not belgian but I play one on TV.

Re: Script heartbeat to show it is still running
by shemp (Deacon) on Jul 03, 2003 at 21:13 UTC
    If your script is taking quite a while to run, its probably a loop or two thats doing most of the work. So, somewhere in your loop, just have your program output a "." every once in a while:
    use constant PROGRESS_CHUNK_SIZE => 1000; my $counter = 0; while ( ... ) { # loop that takes a long time to run ... $counter++; if ( !($counter % PROGRESS_CHUNK_SIZE) ) { print "."; } }
    You may want to alter the PROGRESS_CHUNK_SIZE value, depending on how long 1 loop iteration takes.

      This may or may not work depending on the structure of the OP's code, but if it is going to be useful at all, autoflush will have to be set on the output filehandle. A $|++; near the top of the program will probably suffice.

      -sauoq
      "My two cents aren't worth a dime.";
      
      Thanks!!!!