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

  • Home
  • SEARCH
  • 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 8646975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:57:02+00:00 2026-06-12T12:57:02+00:00

My main intention is to parse the data returned from a traceroute command executed

  • 0

My main intention is to parse the data returned from a traceroute command executed through PHP

$output = shell_exec("traceroute www.xxx.com");
echo $output;

the returned output is something like this

Tracing route to

www.x.com [173.xx.xx.xx] over a maximum of 30 
hops: 1 1 ms <1 ms <1 ms 192.168.1.1 2 10 ms 10 ms 10 ms 117.xx.xx.xx 
3 11 ms 9 ms 9 ms 218.xx.xx.xx 4 10 ms 11 ms 10 ms 218.xx.xx.xx 5 216 ms 220 
ms 229 ms 59.xx.xx.xx.static.xx.xx.xx [59.xx.xx.xx] 6 203 ms 203 ms 219 ms 
121xx.xx.xx
7 328 ms 371  ms 325 ms 72.xx.xx.xx 8 301 ms 306 ms 313 ms 72.xx.xx.xx 9 
249 ms 251 ms249 ms 72.xx.xx.xx 10 256 ms 254 ms 255 ms sin04s02xx.xx.xx
[173.xx.xx.xx] Trace complete.

I want to parse or get the outputs for each time ,

I tried this

traceroute www.google.com 2>/dev/null | awk 'NR==1

{ print $5;
   exit;
}

That gives me the maximum number of hops I think. If there is a command similar to that to get the single outputs like

1 1 ms <1 ms <1 ms 192.168.1.1
2 10 ms 10 ms 10 ms 117.xx.xx.xx
3 11 ms 9 ms 9 ms 218.xx.xx.xx

maybe I can include it in a loop or so.

  • 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-12T12:57:03+00:00Added an answer on June 12, 2026 at 12:57 pm

    You could use popen():

    $handle = popen("traceroute www.xxx.com 2>&1", "r");
    while(!feof($handle)) {
        $buffer = fgets($handle);
        $buffer = "<p>".$buffer."</p>\n";
        echo $buffer;
    }
    pclose($handle);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My intention is to have 4 main Nav-bars at a site. If the user
My intention was to use pyGTK's main loop to create a function that blocks
My main intention is to pass a pointer to a structure, to a function,
I am using a JFrame as a pop-up from a main frame, where the
I wanted to expand my PHP skills so I read through a tutorial on
My main intention is just use some functions in the ann library in Pylab
I'm relatively new to Haskell with main programming background coming from OO languages. I
My main intention was to make getchar return as soon as it gets a
Main need : Resizable widget Minor need : Wide range of Android OS, runs
Main OS is windows 7 64bit. Using VM player to create two vm CentOS

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.