I am really an admirer of "FOR" command.
The possibilities with For command are end less :-)
To generate a simple ping sweeper
Imagine you have to monitor 10 systems for its availability through "ping" command.
Say the systems are in the IP range 10.0.0.1 to 10.0.0.10
C:\> For %i in (1,2,3,4,5,6,7,8,9,10) do ping 10.0.0.%i
It starts pinging the IPs one by one. :-)
Say the systems are in the IP range 10.0.0.1 to 10.0.0.10
C:\> For %i in (1,2,3,4,5,6,7,8,9,10) do ping 10.0.0.%i
It starts pinging the IPs one by one. :-)
Ping sweeper Version II
Now lets change the way we define the set..
C:\> For /L %i in (1,1,10) do ping 10.0.0.%i
Lets analyze (1,1,10) a bit more. Its (start,Step,end). So play it around further !!!
To ping from 10 to 1 it would be
C:\> For /L %i in (10,-1,1) do ping 10.0.0.%i
C:\> For /L %i in (1,1,10) do ping 10.0.0.%i
Lets analyze (1,1,10) a bit more. Its (start,Step,end). So play it around further !!!
To ping from 10 to 1 it would be
C:\> For /L %i in (10,-1,1) do ping 10.0.0.%i
Ping sweeper Version III
Lets play around with the way we defined "set" further.
Lets create a text file containing the following text and name it as list.txt.
10.0.0.1 ;
10.0.0.2 ;
10.0.0.3 ;
10.0.0.4 ;
10.0.0.5 ;
10.0.0.6 ;
10.0.0.7 ;
10.0.0.8 ;
10.0.0.9 ;
10.0.0.10 ;
Lets create a text file containing the following text and name it as list.txt.
10.0.0.1 ;
10.0.0.2 ;
10.0.0.3 ;
10.0.0.4 ;
10.0.0.5 ;
10.0.0.6 ;
10.0.0.7 ;
10.0.0.8 ;
10.0.0.9 ;
10.0.0.10 ;
Now try this.
C:\> For /F "eol=;" %i in (list.txt) do ping %i
It is still a ping sweeper and now the list of systems to be sweeped is taken from the text file speficied.
No comments:
Post a Comment