General discussion


Need help with ping command........

By ak_gates2010 ·

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 -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.


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Use the -n parameter

by Tony Hopkinson In reply to Need help with ping comma ...

Ping pings every second, so
ping -n 3600

should give you an hour's worth

Collapse -

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.

Collapse -

Franky puzzled, what constitutes correct values ?

by Tony Hopkinson In reply to would not give correct va ...

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

Collapse -

Doing this from the Windows command line

by Dumphrey In reply to Franky puzzled, what cons ...

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

Collapse -


by ak_gates2010 In reply to Doing this from the Windo ...

HMMMMMMMMMMM you are right

Collapse -

There you go, I rarely do CLI in windows

by Tony Hopkinson In reply to Doing this from the Windo ...

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

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.

Collapse -

ya it could be But

by ak_gates2010 In reply to There you go, I rarely do ...

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

Collapse -

I think what we all want to know

by neilb@uk In reply to Need help with ping comma ...

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 ?

Collapse -

Yes you are right

by ak_gates2010 In reply to I think what we all want ...

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.

Collapse -

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.

Related Discussions

Related Forums