in reply to Capturing top-like program output

Try taking a look at the man pages for top. If you open it in batch mode (-b) with a single iteration (-n 1), I'm guessing you could capture the output of a single update from top. Process that output, save it, display it or whatever you wanted to do with it, then fetch another screen of output.

Completely untested:

my $n = 1; while( $n < 5 ) { # capture a single screen's worth of output... my $temp = `top -b -n 1`; # process $temp here... # play nice sleep 15; $n = $n + 1; }

Cheers,

Brent

-- Yeah, I'm a Delt.

Replies are listed 'Best First'.
Re^2: Capturing top-like program output
by jettero (Monsignor) on Jan 06, 2007 at 19:36 UTC

    I realize that that -b switch is the simplest answer to Alien's question, but personally, I still wonder how you would capture raw console writes from perl.

    -Paul

      Me too :)