in reply to Expect & top

Capturing the output of top in graphical mode (think it uses curses) is probably not what you want. If you use top's batch mode instead, capturing is much easier, you don't even need Expect:
open PIPE, "top -b -n 1 |" or die "Cannot open"; my $output = join '', <PIPE>; close PIPE or die "Running top failed";

Replies are listed 'Best First'.
Re^2: Expect & top
by tc1364 (Beadle) on Aug 08, 2005 at 19:18 UTC
    ty
      The output from this is much cleaner than using Expect but for example "CPU states: 43.5% idle, 54.2% user, 1.9% kernel, 0.5% iowait, 0.0% swap" line is missing. Could you please help me with obtaining this line?
      open PIPE, "top -b |" or die "Cannot open";