Home > OS >  Bat batch master to solve the problem FOR
Bat batch master to solve the problem FOR

Time:09-28

IP. TXT read
192.168.1.5
192.168.1.6
Then use the following code between PING more IP and writes the result to the E: \ \ log monitoring. TXT
For/f % % I in (IP. TXT) do ((ping % % - n 2 | I find "TTL" & gt; Nul) | | (echo % % I broken network in... ) & amp; & (echo % % I broken network in... ) & gt;> E: \ \ log monitoring. TXT)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

The following code which can realize the interception in the specified character
The set ip_name=192.168.10.1/1111111111
For/f tokens=1 delims="/" % % a (ip_name "% %") in the do (a) set I=% % before rem screenshots "/" character
For/f tokens=2 delims="/" % % b (ip_name "% %") do in rem screenshots (set K=% % b) after "/" character
Echo % I %
Echo % K %
Pause

==================================
Now want to upgrade as follows:
The IP. TXT for user, after the
IP. TXT
192.168.1.5/zhang equipment
192.168.1.6/wang equipment

How to realize the wheel, please PING designated IP. TXT in each IP, and will result in the following format written to the specified file (don't write to file, broken network is written to the log,),
192.168.1.5/zhang equipment broken network in...

CodePudding user response:

Oneself do,
For/f "tokens=1, 2 delims=/" % % a (IP. TXT) do ((ping % % - n 2 | I find "TTL" & gt; Nul) | | (echo % % a & amp; & B broken network in... ) & amp; & (echo % % a & amp; & B broken network in... ) & gt;> E: \ \ log monitoring. TXT)

  • Related