Operating System - HP-UX
1834449 Members
2267 Online
110067 Solutions
New Discussion

Re: How to remove control characters from the output of top

 
JLiYim
Occasional Advisor

How to remove control characters from the output of top

Hi,

I need to find a way to get the output for top into a plain text file which can be sent by email or posted on a web site. I have tried setting the terminal to dumb but top complain about not knowing how to deal with a dumb terminal.

Regards,
John Li Yim
12 REPLIES 12
Rajeev  Shukla
Honored Contributor

Re: How to remove control characters from the output of top

Did you go through the man pages of top probably there is a way to put the output into a file using -f option.

Rajeev
JLiYim
Occasional Advisor

Re: How to remove control characters from the output of top

I have tried top -f but the output still contain control characters. I read that the top utility from http://www.groupsys.com/top/index.html have the -b option to output only text but this utility cannot be compiled on HPUX 11.00.

John
Jose Mosquera
Honored Contributor

Re: How to remove control characters from the output of top

Are sending your output file via ftp? pls remember character conversion via ftp, if you need avoid that characters controls keep, use option ASCII intead BINARY. Another way is use ftp in ascii mode like a *filter* to avoid standar characters controls.

Another way is ussing tr command (translate caracters) to clear not wanted chars, pls see man, is too easy.

sed command may be is usefull to you, i.e:
cat file_in | sed 's/^M//' > file_out
In this case ^M will be replaced by null, in others words, deleted.


Rgds.
U.SivaKumar_2
Honored Contributor

Re: How to remove control characters from the output of top

Hi,

From a windows 98 PC i will telnet and login to unix server and run
#top

Then In the windows telnet window select Edit -> Select all
then Edit -> copy all

I will then paste it to a word file which you can mail. It works without problem.

regards,
U.SivaKumar


Innovations are made when conventions are broken
john korterman
Honored Contributor

Re: How to remove control characters from the output of top

Hi John,
I once tried to make a crontab script execute a top command and afterwards mail the result; tricky because of the many control chars produced by top. The attached script shows my last attempt - which looks unfinished (which it is) but I have just checked that it actually worked on a 11.0 machine where it mailed a nice output to me.
The idea of the script is first to redirect std. error from top to /dev/null, as many of the noisy chars are written to that. Afterwards the control char sequences are replaced by spaces, one by one. Not at very elegant solution, but that might be the way to go.

regards,
John K.
it would be nice if you always got a second chance
Systeemingenieurs Infoc
Valued Contributor

Re: How to remove control characters from the output of top

before you ftp files to an nt or pc, you should try this :
top -s1 -d1 -f fname.top
iconv -f roma8 -t iso81 fname.top >top.txt

or you could user the command ux2dos.

hope this helps.
A Life ? Cool ! Where can I download one of those from ?
Phillip Renner
Advisor

Re: How to remove control characters from the output of top

HI all,

top -d1 -f works form me and I just redirtect it into a file.
Phillip Renner
Advisor

Re: How to remove control characters from the output of top

HI all,

top -d1 -f works for me and I just redirect it into a file.
Kim Kendall
Regular Advisor

Re: How to remove control characters from the output of top

Phillip,
Yes you can get it into a file, and even cat the file and it looks okay. But try to do a more on it, or better yet, try to vi it. You'll see that the formatting is all hosed up.
Frank Slootweg
Honored Contributor

Re: How to remove control characters from the output of top

Adding something like "-n 1000" (show 1000 processes) lets you see all/most processes instead just one 'screen'.
Frank Slootweg
Honored Contributor

Re: How to remove control characters from the output of top

Kim,

On my systems, both 10.20 and 11.0, the "top -d 1 -n 1000 -f filename" output looks fine, both with vi(1) and more(1). Doing a vis(1) on the output file gives an indentical output, i.e. there are no control characters (other than the normal end-of-line linefeed) in the output file.
JLiYim
Occasional Advisor

Re: How to remove control characters from the output of top

"top -d1 -f " works now. I believe that previously the control characters were still appearing in the output file because my terminal setting was not "right".

I have tried it for the past few days and the output is fine now.

Regards,
John Li Yim