Re: Netstat script?
Op zondag 20 februari 2005 08:08, schreef SigmaX:
> 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.
> any help?
> Thanx,
> SigmaX
>
Hello SigmaX,
I think the following script solves your problem.
-----------------------------------------------------------cut--------
#!/bin/bash
clear
read -p "seconds to wait: " value
time2wait=0
SECONDS=0
while [ 0 ];
do
netstat -a|grep tcp
echo "press ctrl-c to exit"
while [ $time2wait -lt $value ];
do
time2wait=$SECONDS
done
clear
time2wait=0
SECONDS=0
done
-----------------------------------------------------------cut--------
If you want to understand how this works, please execute: man bash
greeting,
Martin
Reply to: