MSFN Forum: [Batch] Ping Script ? - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[Batch] Ping Script ? Rate Topic: -----

#1 User is offline   CaTaLinU 

  • Newbie
  • Group: Members
  • Posts: 12
  • Joined: 07-May 12
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 09 May 2012 - 06:06 AM

It is possible to make something like this ...
@ECHO OFF
Title Service Check
CD\
CLS

Rem Step 1:
Ping 95.76.53.219
echo Your connection to the 95.76.53.219 is %ms%
Pause


I want to show only the average Ms ...

it is possible ?


#2 User is offline   bphlpt 

  • MSFN Expert
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,082
  • Joined: 12-May 07

Posted 09 May 2012 - 11:06 AM

[Barely resisting the urge to simply answer your question "Yes, have a nice day :)"]

@ECHO OFF
(Set "addr=95.76.53.219")
FOR /F "skip=10 tokens=4 delims==" %%G IN ('Ping %addr%') DO ECHO Your connection to %addr% is %%G
Pause


This does no error checking at all and assumes that ping returns the standard response and does not time out.
Reference: http://ss64.com/nt/for_cmd.html

Cheers and Regards

#3 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,364
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 09 May 2012 - 11:38 AM

Is there a particular reason why you are looking for the average round trip time from four pings with a one second timeout?

BTW I'd probably change the above example to this
@ECHO OFF & SETLOCAL ENABLEEXTENSIONS
(SET addr=95.76.53.219)
FOR /F "TOKENS=4 DELIMS==" %%# IN ('PING %addr%^|FIND "Average"') DO (
    ECHO=Your connection to %addr% is%%#)
PAUSE


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy