Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7873825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:37:37+00:00 2026-06-03T02:37:37+00:00

I have written the following system command to ping a website which gives me

  • 0

I have written the following system command to ping a website which gives me desired ICMP response.

response = system("ping -c1 www.stackoverflow.com")

The response is as–

PING stackoverflow.com (64.34.119.12) 56(84) bytes of data.
64 bytes from stackoverflow.com (64.34.119.12): icmp_req=1 ttl=52 time=336 ms

--- stackoverflow.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 336.699/336.699/336.699/0.000 ms
 => true

Now i want to store the average time from the above statistics. So i hit the next system command which is as.

response_time = system("ping -c 1 www.pintile.com | tail -1| awk '{print $4}' | cut -d '/' -f 2")

This gives me the average time but does not store it in the response_time variable. Tha value stored in response_time is true.

335.898
 => true 

Now my question is How to store the average time in the response_time variable??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:37:39+00:00Added an answer on June 3, 2026 at 2:37 am

    use curl :

    curl -w '\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n' -o /dev/null -s http://www.pintile.com
    

    you will get the output like :

    Lookup time:    0.589
    Connect time:   0.603
    PreXfer time:   0.603
    StartXfer time: 1.425
    
    Total time: 2.073
    

    hope that help .

    EDITED :

    Check this answer.

    If you surround your command with backticks, then you don’t need to (explicitly) call system() at all.

    Use it like :

    response_time = `ping -c 1 www.pintile.com | tail -1| awk '{print $4}' | cut -d '/' -f 2`
    

    Now you will get response_time . 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written the following IronPython code: import clr clr.AddReference(System.Drawing) from System import *
I have written the following: var pages=[[www.google.co.uk] This is the WWW. ,[www.yahoo.co.uk] This is
I have written the following program which connects to two LDAP stores, compares the
I have written a piece of code which uses System.ServiceModel.Syndication library to parse RSS
i have written a following hbase client class for remote server: System.out.println(Hbase Demo Application
I have written following code to attach gesture recogniser to multiple imageviews. [imageview1 setUserInteractionEnabled:YES];
I am trying my hands on WPF MVVM. I have written following code in
I have written the following constraint for a column I've called 'grade': CONSTRAINT gradeRule
I have written the following Utility class to get an instance of any class
I have written a following code to get just the file name without extension

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.