Title: RE: [Perl-unix-users] Reading Unix's top command

Thanks for the hint Bill, that has put the output file into some sort of readable format now.

Do you know what the following corresponds to, so i can get rid of it as well:

^[[B

thanks

Kareem

-----Original Message-----
From: $Bill Luebkert [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 2 October 2003 12:15 PM
To: Kareem Galal
Cc: [EMAIL PROTECTED]
Subject: Re: [Perl-unix-users] Reading Unix's top command


[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:
>
> 1 running^M^[[BCpu states:^M^[[BCPU
>
> Is there a way to parse the file, as you would go through a normal text
> file.

You could just convert the ^M (\r) to newlines and then you can remove
the escape sequences if needed or just work around them.

        tr/\r/\n/;
or
        s/\r/\n/gs;

--
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

Reply via email to