Therefore, you need to use batch for this. Basically, HOSTNAMES servers are listed in a txt file. I used the following code to check all servers and display their results in txtfile.
For /f %%i in (testservers.txt) do ping -n 1 %%i >>pingtest.txt
All servers pinged the above. Now I want to output the IP addresses and HOST names to a separate file. How can i do this? I know that I can run a for loop to search for words such as "TTL", and then search for the third token (for IP) and words like "PINGING" for the second token (HOSTNAME). But I have errors and cannot display it correctly. The reason I want to display the IP addresses and host names in another file is to create a list of DOWN and UP servers.
Help will be appreciated. :)
EDIT: just so that it doesn't bother, I would like you guys to know that there are 3 different files, testervers.txt has HOSTNAMES, pingtest.txt has ping results, and result.txt will have IP addresses along with hostnames with their current status as DOWN or UP.
source share