h123 has asked for the wisdom of the Perl Monks concerning the following question:
My perl script executes a command on unix box and saves the output to a filehandler. The command it executes prints lines of stats every 10 seconds to standard out.
The command the perl script executes will always run and if the program it is trying to get the stats for isn't available then it just waits until the program is back up again. What I want to do is print the text "No data" if there are no more new lines after 10 seconds?
This is the code so far:open(STATISTICS, "/home/<app>/client/bin/<stats> -c usage_counter 2> +/dev/null |") || die "can't fork: $!"; while (<STATISTICS>) { print $_; } close STATISTICS || die "ERROR : $! $?";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Check for a new line
by kcott (Archbishop) on Jan 28, 2014 at 01:26 UTC | |
by h123 (Novice) on Jan 28, 2014 at 09:19 UTC | |
by h123 (Novice) on Jan 28, 2014 at 14:03 UTC | |
by kcott (Archbishop) on Jan 29, 2014 at 05:22 UTC | |
by h123 (Novice) on Jan 29, 2014 at 09:39 UTC | |
|
Re: Check for a new line
by jellisii2 (Hermit) on Jan 27, 2014 at 12:25 UTC | |
by h123 (Novice) on Jan 27, 2014 at 12:35 UTC | |
by jellisii2 (Hermit) on Jan 27, 2014 at 12:46 UTC | |
by h123 (Novice) on Jan 27, 2014 at 15:17 UTC | |
by dasgar (Priest) on Jan 27, 2014 at 15:46 UTC | |
by jellisii2 (Hermit) on Jan 27, 2014 at 15:41 UTC |