title: How to ping multiple servers and return IP address and Hostnames using batch script?
body: <p>So I have to use <strong>batch only</strong> for this. Basically, the server HOSTNAMES are all listed in a txt file. I used the following code to ping all the servers and display their results in a txtfile. </p>
  
  <pre><code>For /f %%i in (testservers.txt) do ping -n 1 %%i &gt;&gt;pingtest.txt
  </code></pre>
  
  <p>The above pinged all the servers. Now, I want to output the IP addresses and the HOST Names in a separate file. How can I do this?
  I know that I can run a for loop searching for words like "TTL" and then look for the 3rd token (for the IP) and words like "PINGING" for the second token(HOSTNAME). But I am having errors and cant display it properly. The reason why I want to output IPs and Hostnames in a different file is to make a list of the DOWN and UP servers. </p>
  
  <p>Help will be appreciated. :)</p>
  
  <p>EDIT: Just so it isn't confusing, wanted to let you guys know there are 3 different files, testservers.txt has the HOSTNAMES in it, pingtest.txt has ping results, and result.txt will have the IPs along with Hostnames with their current status as DOWN or UP.</p>