Register
It is currently Mon Dec 22, 2014 8:36 pm

Ping Average Time


All times are UTC - 6 hours


Post new topic Reply to topic  [ 5 posts ] 
Author Message
 PostPosted: Tue Mar 09, 2010 12:57 am   

Joined: Tue Mar 09, 2010 12:54 am
Posts: 4
Location: Assiut, Egypt
hi all,
I need to ask, how using bash i can do ping for 10 times and get the Average time to put it in some variable ???


Top
 Profile WWW YIM  
 PostPosted: Tue Mar 09, 2010 1:05 am   

Joined: Tue Mar 09, 2010 12:54 am
Posts: 4
Location: Assiut, Egypt
i forget to say, that i will use this time average to make some processes to make a certain job :D


Top
 Profile WWW YIM  
 PostPosted: Tue Mar 09, 2010 4:22 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
The following should display the average time;

Code:
ping -qc 10 localhost | awk -F/ '/^rtt/ { print $5 }'


Of course this assumes that your ping outputs like the one I'm using.
If this doesn't seem to work then post the output of "ping -qc 10 localhost"

=:)


Top
 Profile  
 PostPosted: Tue Mar 09, 2010 6:17 am   

Joined: Tue Mar 09, 2010 12:54 am
Posts: 4
Location: Assiut, Egypt
thanks for your time, but i need to put $5 variable in some new parameter named y...


Top
 Profile WWW YIM  
 PostPosted: Wed Mar 10, 2010 7:59 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
There are many many many many examples of how to do that, but here it is again;

Code:
myvar="$(ping -qc 10 localhost | awk -F/ '/^rtt/ { print $5 }')"


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP