in reply to Obtaining data from the top command via a pipe
I tested this on a Sun-Fire-280 running Solaris 9 and I am not a Unix guru so your mileage may vary. Best of luck.#!/usr/bin/perl use warnings; use strict; open (PIPE, "/usr/local/bin/top -b -d2 |") or die "Cannot open top: $! +"; while (<PIPE>) { if (/^CPU/) { print; last; } } close(PIPE); exit(0);
Updated: removed temporary variable for input line.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Obtaining data from the top command via a pipe
by tc1364 (Beadle) on Aug 10, 2005 at 14:03 UTC |