Announcement

Collapse
No announcement yet.

Newbie scripting for pinging

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newbie scripting for pinging

    Hello REMS,
    WAY BACK in Jan.2008 you posted a reply to:
    Re: Script or batch file to ping machine names

    --------------------------------------------------------------------------------------------------------
    Originally posted by Rems View Post
    It is easier to create a seperate file containing the names or ip-addresses of the computers,
    "File= Computers.txt"

    computer1
    computer2
    computer3
    x.x.x.x
    .
    .
    Here a batch that reads the computernames/addresses from the file, and ping them.
    Code:
    @echo off
    
    (Set InputFile=c:\Computers.txt)
    
    title,Pinging list of computers &color 9e
    
    ::datestamp
    for /f "tokens=2-4 skip=1 delims=(-./)" %%i in ('echo.^|date') do (
       for /f "tokens=1-4 delims=-./ " %%m in ('date /t') do (
          (set dow=%%m)&(set %%i=%%n)&(set %%j=%%o)&(set yy=%%p) ) )
    For /F "tokens=1,2 delims=:, " %%i in ('TIME /T') Do (Set HHMM=%%i%%j)
    
    (Set OutputFile=c:\Pinglog %yy%-%mm%-%dd% %HHMM%.txt)
    
    If Exist "%OutputFile%" Del "%OutputFile%"
    
    For /F "eol=;" %%* in ('type "%InputFile%"') do (
     >>"%OutputFile%" (echo.&echo.---------------&(
     echo.%%*;&(ping -a -n 2 -w 750 %%* | Find "."))
     )&echo.done %%*,)
    
    
    ::check
    start notepad.exe %OutputFile%
    The results are going to be written to a logfile with a date/time stamp in the file name.
    --------------------------------------------------------------------------------------------------------

    This is a great batch file. I do not know how to write them, but this works.
    I would LOVE to learn what each part of this script does and the commands you can use in whatever scripting language this is.
    Can you point me to a VERY SIMPLE TUTORIAL?

    Also, at the end of each entry in this log file, it shows the following statement:
    "Ping statistics for xxx.xxx.xxx.xxx:"

    BUT does not actually show the statistics (like packets sent, received, lost, etc.) -- why not? am I doing something wrong?

    I would've posted to this thread but apparently it is "closed" so I guess you can't reply to it...
    Last edited by Rems; 27th November 2012, 17:31.

  • #2
    Re: Newbie scripting for pinging

    Originally posted by mhinkle View Post
    Also, at the end of each entry in this log file, it shows the following statement:
    "Ping statistics for xxx.xxx.xxx.xxx:"

    BUT does not actually show the statistics (like packets sent, received, lost, etc.) -- why not? am I doing something wrong?

    I would've posted to this thread but apparently it is "closed" so I guess you can't reply to it...
    It is not there because,,,
    The | Find "." statement after ping -a -n 2 -w 750 %%* make the output show only the lines containing a dot. If you would remove | Find "." then every line wil be echoed, except for the empty lines.

    /Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: Newbie scripting for pinging

      Thank you!
      this will help me tweak this script, now I just need to learn what all these commands do individually so I can actually start creating my own bats!!

      Comment

      Working...
      X