Computing.Net > Forums > Disk Operating System > batch script help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch script help

Reply to Message Icon

Name: Tigerbalm
Date: February 27, 2003 at 15:19:43 Pacific
OS: Win2000
CPU/Ram: PIII
Comment:

Is there any way to return a list (directory listing, for instance) and EXCLUDE certain entries in the returned list based on specific parameters?

For instance, let's say I ran a "netstat" command to see the current active connections to my machine. I might get 5 entries, for instance, 2 of which are private IP connections from other PCs, and 3 from HTTP sites. If I'm only interested in returning ONLY the 2 private IP connections in the list, is there a command or method I can use to achieve this? In other words, I'd like the returned list to ignore or filter out all the HTTP selections.




Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: February 27, 2003 at 18:02:52 Pacific
Reply:

You can achieve such goals with the FOR command, using its /F switch.

In the example you've given, this would only display the non-http IPs:

for /F "tokens=*" %%A in ('netstat') do (
  echo %%A|FIND /I ":http" > nul
  if errorlevel=1 echo %%A
)

I'm not going to write a tutorial about the command for you, but you can get almost all the information you need on its own documentation: on the command prompt, type "FOR/?".

Keep in mind that the FOR cmd does only have this "advanced features" like the /D /F /L and /R switches on NT systems (Windows NT, 2000 and XP), not on Win9x nor DOS.

If any questions come up as you study the command (there isn't much to learn, it's not a cmd like SED), ask them on this forum!

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 2
Name: tHe mAdd pRoFeSsOr
Date: March 15, 2003 at 04:10:11 Pacific
Reply:

dir | find /v >>filename
is the filter for that



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: batch script help

batch scripts I NEED HELP www.computing.net/answers/dos/batch-scripts-i-need-help/1772.html

batch script to install SP3 HELP! www.computing.net/answers/dos/batch-script-to-install-sp3-help/13053.html

Creating a BATCH script www.computing.net/answers/dos/creating-a-batch-script/163.html