| Login

Search this Blog


Links I like to keep around




Here are the most recent postings to this blog. Use the archive calendar or search to find other entries.
Nov17

Written by:R Teachout
11/17/2006 2:27 AM

::__________________________________________________________________
::
::  Batch File:      PingRange.cmd
::  Author:          Frank-Peter Schultze
::
::  Updates:         http://www.fpschultze.de/modules/news/article.php?storyid=15
::  Enhancement Req.
::  And Bug Reports: support@fpschultze.de
::
::  Built/Tested On: Windows 2000
::  Requirements:    OS: Windows NT4+ w/ enabled cmd. extensions
::
::  Purpose:         Ping a subnet
::
::  Syntax:          PingRange subnet_id
::
::  State Changes:   -
::
::  Assumptions And
::  Limitations:     -
::
::  Last Update:     2004-02-28
:: __________________________________________________________________
::
  @Echo Off
   Set @=
   For /L %%J In (1,1,4) Do Set SubId%%J=
   For /F "Tokens=1-4 Delims=." %%J In ("%1") Do (
     Set SubId1=%%J
     Set SubId2=%%K
     Set SubId3=%%L
     Set SubId4=%%M
   )
   For /L %%J In (1,1,4) Do If Not Defined SubId%%J Set @=%%J
   If Defined @ Goto Error
   For /F "Tokens=1-4 Delims=0123456789" %%J In (
    "%SubId1%.%SubId2%.%SubId3%.%SubId4%"
   ) Do Set @=%%J%%K%%L%%M
   If Not {%@%}=={...} Goto Error
::
:: Check 1-126.*.*.* (Class A)
::
   For /L %%J In (1,1,126) Do (
     If {%SubId1%}=={%%J} (
       Call :Class_A %SubId1%
       Goto :EOF
     )
   )
::
:: Check 128-191.*.*.* (Class B)
::
   For /L %%J In (128,1,191) Do (
     If {%SubId1%}=={%%J} (
       Call :Class_B %SubId1% %SubId2%
       Goto :EOF
     )
   )
::
:: Check 192-223.*.*.* (Class C)
::
   For /L %%J In (192,1,223) Do (
     If {%SubId1%}=={%%J} (
       Call :Class_C %SubId1% %SubId2% %SubId3%
       Goto :EOF
     )
   )
   Goto Error

  :Class_A
   For /L %%J In (0,1,255) Do Call :Class_B %1 %%J
   Goto :EOF

  :Class_B
   For /L %%J In (0,1,255) Do Call :Class_C %1 %2 %%J
   Goto :EOF

  :Class_C
   For /L %%J In (1,1,254) Do (
     Echo Pinging %1.%2.%3.%%J
     Ping -n 1 %1.%2.%3.%%J | Find /I "TTL="
     Echo ------------------------------------------------
   )
   Goto :EOF

  :Error
   Echo Invalid subnet ID - %1
   Echo.
   Echo Syntax  : %~n0 subnet_id
   Echo Example : %~n0 192.168.13.0
  :End
   Set @=

 

Download:  PingSubnet.cmd.txt

Tags:


-quoteworld.org

Inspired by Nina