As i was trying to use your -b option, i realized there was a:
-f filename
option on Unix, which printed out the output of top to filename, in a readable format.
Thanks you all for your help
kareem
-----Original Message-----
From: Michael A Nachbaur [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 7 October 2003 3:22 AM
To: Kareem Galal; [EMAIL PROTECTED]
Subject: Re: [Perl-unix-users] Reading Unix's top command
On Wednesday 01 October 2003 07:06 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> In order to get an email advising me that a process is using too much %cpu,
> i wanted to be able to redirect the output of the Unix top command into a
> text file, then use regular expressions to get the data i need.
> However, redirecting top's output into a file, ends up being one long line
> with a lot of control-M characters and other funny characters like these:
Another way is to call top in batch mode (-b). This tells top to not send any
fancy control characters. If you want to catch just one iteration though,
you should also pass it "-n1" so that it doesn't just scroll screenfulls of
top information on your terminal.
Attached is a little quickie program I wrote to watch various aspects of top's
output over time. It might help to show how one could process top data.
--
/* Michael A. Nachbaur <[EMAIL PROTECTED]>
* http://nachbaur.com/pgpkey.asc
*/
"He expanded his chest to make it totally clear that here
was the sort of man you only dared to cross if you had a
team of Sherpas with you. "