[EMAIL PROTECTED] wrote:
> 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
That's just a terminal sequence to position the cursor.
Do a search for ANSI terminal escape sequences to get a list.
ESC[PnB
Cursor Down: Moves the cursor down by the specified number of lines
without changing columns. If the cursor is already on the bottom line,
ANSI.SYS ignores this sequence.
> -----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)
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs