Re: Netstat script?
On Saturday 19 February 2005 02:52, Rus Foster wrote:
>On Sun, 20 Feb 2005, SigmaX wrote:
>> I know nothing about scripting, but I want to write/obtain a
>> script that displays the results of the command "netstat -a | grep
>> tcp", then clears the screen and does so again a few seconds
>> later. Else I just need a program that does something similar in
>> the console, so I can view it over SSH.
>
>A very simple one for this
>
>#!/bin/bash
>
>while [ 1 ] ; do
>
> netstat -a | grep tcp
> sleep 1 # This is number of seconds
> clear
>
>done
>
>That should do what you want on a very basic level
>
>Rus
This one, after the first iteration, changes only that data which is
changed, with no screen flickers etc here.
----------
#!/bin/bash
reset
while [ 1 ] ; do
netstat -a | grep tcp
reset
sleep 5 # This is number of seconds
done
----------
If you want to see the cursor move from bottom to top, trade the reset
and sleep commands around, giving some indication that its actually
running when watching a quiet system.
>--
>e: rghf@vpscolo.com : t: 1-888-327-6330
>http://www.vaserv.com - Coming soon. Email sales@vaserv.com for more
> info http://www.storemypic.com - Free Image Hosting
>http://www.vpsforums.com - Talk for VPS users and Providers
>http://www.jvds.com - VPS Hosting for the geeks
--
Cheers, Gene
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
99.33% setiathome rank, not too shabby for a WV hillbilly
Yahoo.com attorneys please note, additions to this message
by Gene Heskett are:
Copyright 2005 by Maurice Eugene Heskett, all rights reserved.
Reply to: