cmd.exe script
Hi, I am not very famaliar with cmd.exe scripting. I need some help. I have a .bat file with a for loop that loops a text file of DNS names and pings those names. However, i want to append the DNS name to the result so I now which was successful. Below is my script. I want to append %%a to the {find "Pinging" } output then output that to the o.txt file. I'm sure this will be easy, but I will appreciate greatly. @echo off for /f "tokens=1 delims=" %%a in (scanDNS2.txt) do (ping.exe %%a | find "Pinging" >> o.txt ) thanks Dave
March 26th, 2010 2:13am

Hi Dave, I suggest you post your scripting queries next time to The Official Scripting Guy Forum. =) That said, you can instead look for the "Reply" string from the output to see which machines reply to your ping requests. @echo offfor /f "tokens=1 delims=" %%a in (scanDNS2.txt) do (ping -n 1 %%i | findstr "Reply" > nulif not ERRORLEVEL 1 @echo %%i >> o.txt ) Regards,Salvador Manaois IIIMCSE MCSA MCTS MCITP C|EH CIWA ----------------------------------------------------------------------------Bytes & Badz: http://badzmanaois.blogspot.comMy Passion: http://www.flickr.com/photos/badzmanaoisMy Scripting Blog: http://sgwindowsgroup.org/blogs/badz
Free Windows Admin Tool Kit Click here and download it now
March 26th, 2010 8:55am

Hi Salvador, Thank you so much for replying. It doesn't seem to be working for me. Though I think I can figure it out from what you have provided by looking up the commands. I develop in C# and this is so much more cryptic, but kind of cool. I have pinged the DNS names manually and I do get a response in the command window so I'm not sure why it isn't working. If you have time to look it over a bit more that would be appreciated. Thanks for the reference to the Scripting guy forum also. Dave
March 27th, 2010 8:08pm

Hi Salvador, i think I know why it wasn't working. The "for" statment defines %%a, but I am pinging %%i. Changing %%a to %%i seemed to do the trick. Thanks again!
Free Windows Admin Tool Kit Click here and download it now
March 29th, 2010 3:56am

My apologies, there was a typo in my script. You are correct, the %%a should be changed to %%i (or vice versa) for the script to run. I wasn't able to test the script before posting. =) Regards,Salvador Manaois IIIMCSE MCSA MCTS MCITP C|EH CIWA ----------------------------------------------------------------------------Bytes & Badz: http://badzmanaois.blogspot.comMy Passion: http://www.flickr.com/photos/badzmanaoisMy Scripting Blog: http://sgwindowsgroup.org/blogs/badz
March 29th, 2010 10:01am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics