General discussion

  • Creator
    Topic
  • #2241979

    Need help with ping command……..

    Locked

    by ak_gates2010 ·

    Hi,

    I am actually having some issues with ping command,
    I have a scenario where in i am having to run a contineous ping i.e ping google.co -t.
    Now what i want is to use ctrl+beak after every hour.
    i do not wish to press ctrl+beak manually, it should be done automatically after every hour.

    Could some one please help me to create a batch file with this fuctionality.

    Please help and revert at your earliest.
    Thanks in advance.

    MD

All Comments

  • Author
    Replies
    • #2643764

      Use the -n parameter

      by tony hopkinson ·

      In reply to Need help with ping command……..

      Ping pings every second, so
      ping -n 3600 google.co

      should give you an hour’s worth

      • #2640548

        would not give correct values……

        by ak_gates2010 ·

        In reply to Use the -n parameter

        Hi Tony,
        Thanks for the reply, However if i use -n parameter, it may work in some cases like if the site is working properly and may vary from site to site as well. But in case there are a number of RTO’s it will take more than an hour to send the same number of echo requests.
        So what i want is exatcly after one hour there must acour a CTRL+BREAK action No matter how many packets are sent in that perticular hour.

        Please Help with the same.

        • #2644762

          Franky puzzled, what constitutes correct values ?

          by tony hopkinson ·

          In reply to would not give correct values……

          How long do yu wait for a response, do you care if you get one?
          Is there some metric for x responses per hour?

          It sounds like you are pinging in response to a success or fail.
          Not big on this sort of scripting , but coding wise you need to do something like
          store the time

          loop while curent time – starttime < 1 hour ping once (do something with result ?) end loop

        • #2644735

          Doing this from the Windows command line

          by dumphrey ·

          In reply to Franky puzzled, what constitutes correct values ?

          while be very difficult. Loops do not work well there, and the midnight time shift could cause problems.

        • #2645042

          hmmm

          by ak_gates2010 ·

          In reply to Doing this from the Windows command line

          HMMMMMMMMMMM you are right

        • #2645041

          There you go, I rarely do CLI in windows

          by tony hopkinson ·

          In reply to Doing this from the Windows command line

          My typical approach to this sort of thing would be to write a program. :p

          That I can do.

          In Linux I’d probably knock up a perl script, to do anything ‘complex’, maybe something like Python would be a better approach for this sort of thing.

        • #2645030

          ya it could be But

          by ak_gates2010 ·

          In reply to There you go, I rarely do CLI in windows

          Ya Tony. it we couyld go that way,,,,,,,,, But i am usin windows and i wanna do all this with batch ptogramming………..
          so all dos command are to used..

          Please trying to get some thing which i lso can understand

    • #2644716

      I think what we all want to know

      by neilb@uk ·

      In reply to Need help with ping command……..

      is actually what you want to achieve. There might be a better way!

      The way I’d probably do it is to have a batch file that constantly fires up ping -t in a loop and have another program running that waits for an hour and then kills the ping process and then goes back to sleep. But why would I?

      Neil ?:|

      • #2645047

        Yes you are right

        by ak_gates2010 ·

        In reply to I think what we all want to know

        Ya neil…… This is something i want.
        Actually i need to have ping response of every hour for perticular site so that i could analyze how many packets were lost in which pertilar hour,

        I am directing ping response to one text file , it has every thing i want except one thing. that is every hour i need to press ctrl+break to check the packet loss.
        I want this function to automate.

        Now i think the whole picture should be clear.

        Please help to get it done.

        • #2645037

          Something like.

          by tony hopkinson ·

          In reply to Yes you are right

          One progrm that simply pings contunually and writes to txt file, you already have.
          An other program that’s scheduled to run once an hour
          That kills the pinger, analyses the output, stores it somewhere else (another txt file ?)
          delets / moves the pinger output file
          Then starts up the pinger again, is probably the way to go then.

          Using the scheduler for the timer and separating collection from analysis / reporting should solve most of your problems.

          Get a bit clever with the analysis and how often you run the reporter process is your data length.

          so if something goes wrong you can work out how long the process was running for and pro-rata the data into a per hour figure.

        • #2644416

          Here you go

          by neilb@uk ·

          In reply to Yes you are right

          Save the bit between the dashed lines as killping.vbs. Run it with the Windows Scheduler and it will shut down any running ping processes.

          ‘————————-
          Set objWMI = CreateObject(“wbemScripting.Swbemlocator”)
          Set objServer = objWMI.ConnectServer

          Set colProcesses = objServer.InstancesOf(“Win32_Process”)
          For each objProcess in colProcesses
          If objProcess.Name = “ping.exe” Then
          objProcess.Terminate
          End If
          Next
          ‘————————-

          You can also use TASKKILL.EXE from the command line. It’s supplied with XP but I can’t stop myself writing scripts.

          Neil 😀

Viewing 1 reply thread