LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Clear screen after every netstat update (https://www.linuxquestions.org/questions/linux-newbie-8/clear-screen-after-every-netstat-update-4175533024/)

skoda 02-04-2015 05:46 AM

Clear screen after every netstat update
 
Hi folks,

When i past this on the shell, the command rungs, but it does not clear previous data on each update.

Quote:

@echo off
:GoAgain
clear
netstat -atnp -w 5 | grep ESTA
goto GoAgain
what could be wrong?

michaelk 02-04-2015 07:12 AM

Since this appears to be a windows batch file the correct syntax for clearing the screen is cls not clear.

skoda 02-04-2015 07:19 AM

Quote:

Originally Posted by michaelk (Post 5311769)
Since this appears to be a windows batch file the correct syntax for clearing the screen is cls not clear.

Hi michelk,

nop, problem remain same

Quote:

@echo off
:GoAgain
cls
netstat -atnp -w 5 | grep ESTA
goto GoAgain

veerain 02-04-2015 07:32 AM

Is this a shell script in linux?

Then goto command doesn't works.

So you have to put 'clear' command after netstat command.

Also for looping you would use the keywords 'while' or 'until'.

michaelk 02-04-2015 07:32 AM

Then please explain your environment i.e is this just a command window etc.

skoda 02-04-2015 10:46 PM

Thanks folks,
this is centos 6.x shell.

ill take a look at while and until functions.

chrism01 02-05-2015 05:16 AM

Here's a good cli tutorial http://rute.2038bug.com/index.html.gz

rnturn 02-08-2015 08:30 PM

Quote:

Originally Posted by veerain (Post 5311782)
Is this a shell script in linux?

Agreed. I think I'm having a flashback to my DOS batch file days.


All times are GMT -5. The time now is 06:31 PM.