#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2007
    Posts
    3
    Rep Power
    0

    Unhappy Anybody know how to do a ping sweep in DOS and save the output?


    I am a relative newbie at this and need assistance. I know that you can do a for loop in DOS by doing the following:
    for /f %%i in (a text file with machine names) do ping >c:\results.txt

    When I run this it seems to iterate through the file and prints the command to the .txt file. It doesn't print what machines responded... HELP!!!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2007
    Posts
    3
    Rep Power
    0
    Guess not...

    Originally Posted by Dante68
    I am a relative newbie at this and need assistance. I know that you can do a for loop in DOS by doing the following:
    for /f %%i in (a text file with machine names) do ping >c:\results.txt

    When I run this it seems to iterate through the file and prints the command to the .txt file. It doesn't print what machines responded... HELP!!!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2007
    Posts
    3
    Rep Power
    0

    came up with the script


    Originally Posted by Dante68
    Guess not...
    @echo off

    type nul>pass.txt

    type nul>fail.txt

    for /f %%a in (machines.txt) do call :ping %%a

    goto :EOF

    :ping

    echo testing %1

    ping %1|find /i "TTL=">nul

    if %errorlevel%==0 echo pass&echo %1>>pass.txt

    if %errorlevel%==1 echo FAIL&echo %1>>fail.txt
  6. #4
  7. Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    New Springfield, OH
    Posts
    1,247
    Rep Power
    1469
    This a better job for WSH, but if it works great.
    Don't like me? Click it.

    Scripting problems? Windows questions? Ask the Windows Guru!

    Stay up to date with all of my latest content. Follow me on Twitter!

    Help us help you! Post your exact error message with these easy tips!
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2006
    Posts
    271
    Rep Power
    16
    Try ping -a whatever

    On Windows that'll report the machine name as part of the ping output.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2010
    Posts
    1
    Rep Power
    0
    type the following in CMD window:

    for /L %z in (1,1,254) do @ping 10.200.0.%z -w 10 -n 1

    explanation as follows:

    (1,1,254) = starting point (last value in IP address represented by '%z'), ping increment (if you set to 10, then it will ping .10, .20, .30, etc), and 254 is ending point

    the '-n1' at the end is how many times to ping an IP

IMN logo majestic logo threadwatch logo seochat tools logo