hi all

using telnetlib, I am issuing a 'top' command on a remote host. Top seems to continue indefinitely. On a terminal, I can use CTRL+c to suspend the process...


What can be passed in telnet.write() equivalently to suspend the process , yet retain the output so far...


pls help me out....:S

Recommended Answers

All 6 Replies

Perhaps use top's -n option ?

~ # top -n 3
top: invalid option -- n

got this............

~ # top -n 3
top: invalid option -- n

got this............

Well, top -n 3 works for me (Mandriva Linux release 2010.2 (Official) for x86_64
Kernel 2.6.33.7-desktop-2mnb on a Dual-processor x86_64 / \l) but it seems that there are different versions of top, because online manuals don't have the same interpretation of -n as my manual. I have

-n : Number of iterations limit as:  -n number
            Specifies  the  maximum  number of iterations, or frames, top
            should produce before ending.

On the other hand, this link http://www.manpagez.com/man/1/top/ gives

-n <nprocs>
              Only display up to <nprocs> processes.

Note that the syntax top n 3 is accepted on my machine, as described here http://linux.die.net/man/1/top .
Try which top and check that your top is not a symlink.

Edit: I realized that the manpagez.com manual is for Mac OSX.

Thanks Grib...

well, I dont know how to put the things in words.

The host I am running the 'top' command on is a proprietary unit of the company's client.

uname -a gives me just Linux XXXX, said to be having kernel version 0.3.4.

I don't know further details,but, top -n is not working :(

Thanks Grib...

well, I dont know how to put the things in words.

The host I am running the 'top' command on is a proprietary unit of the company's client.

uname -a gives me just Linux XXXX, said to be having kernel version 0.3.4.

I don't know further details,but, top -n is not working :(

See if man top gives you useful options. Also, it's a little strange to run top through telnet. Can't you replace it with ps aux ?

Also you could save the output of top to a file and then cat the file. Google with save the output of top :)

hey..got a way. Running top in background (top &) and issuing killall after some delay.:D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.