Capturing Unix Traceroute data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capturing Unix Traceroute data
Prev   Next
# 1  
Old 10-19-2007
Capturing Unix Traceroute data

Hi guys,

I need a way to capture the host on the next-to-last hop in a traceroute output.

The last output is the destination but I need to capture the router just before the last hop.

I can do this in perl but I'm not so sure about Shell...

I'm on AIX 5.3 using ksh

any ideas?

Thanks,
Mike
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl : not capturing all the data from excel sheet

Hi folks, I am working on assignment that captures all the records(2 columns one column contains names and other contain date of birth) from excel sheet stored in a directory and checks for current date and month. If it matches current date and month then the matched records are printed as... (1 Reply)
Discussion started by: giridhar276
1 Replies

2. Shell Programming and Scripting

capturing selective data from a vcd file

Hi, This is a vcd file.A vcd file may have 'n' modules. 1) I need to capture the data in bold,i.e. the module names (shown in bold) 2) Also i need to capture the data inside each individual module,say for tst_bench_top ,i need to capture data from line 4 to line 20 ... I just want one... (2 Replies)
Discussion started by: veerabahu
2 Replies

3. Red Hat

capturing data of nethogs

I have installed nethogs to see which process is sending load on the network. i would like to know how can i capture its data in a log file. Or is there is a unix command like script or tee which can help me to capture the data using cronjob (0 Replies)
Discussion started by: anshus1
0 Replies

4. IP Networking

How to capturing packet data so i can see the Version, IHL, TOS, etc?

Helo Folks :) i had read an answer in this thread unixcom/programming/117551-calculate-ip-header-checksum-manually.html i need to know what the software name that was used to capturing packet data in a network, just like the packet's capture output that showed up in the thread. Thank you :)... (5 Replies)
Discussion started by: polutan
5 Replies

5. Shell Programming and Scripting

Capturing data between patterns

Hii, Friends, I want your help in one of my problem. My problem is as follows. I have a flat file as follows (Just a sample) MHT011 01(DOT)8750707asdfas8609 03(DOT)ASD3453ASD 09(DOT)876JHT87 11(DOT)sfd324ert TTT077 01(MOB)876786klj897 06(MOB)876JHT87 07(MOB)sfd324ert... (4 Replies)
Discussion started by: anushree.a
4 Replies

6. Shell Programming and Scripting

Capturing SQL O/P in Unix Script

Hi, I would like to run a job based on the output from the SQL output. Eg: Select count(*) from A ...if count(*) = 1 then execute the next step or else exit. Please advise. Thanks S (2 Replies)
Discussion started by: pyaranoid
2 Replies

7. Shell Programming and Scripting

Capturing Particular Data

Hi everyone! Can any one help me out regarding capturing relevant data from a file. For e.g, if i want to capture the comment written after "Prompt:" for a particular date, like for this case what would be the command to capture the tag written after "Prompt:" for Date: 2009-03-20. A... (7 Replies)
Discussion started by: muhmsida
7 Replies

8. Shell Programming and Scripting

Capturing Data between first quote and next quote

I have input file like RDBMS FALIURE UTY8703 'USER_WORK.TEST' .HIghest return code '12' I want to parse data which comed between first quote till next quote USER_WORK.TEST can you please suggest how to do that (4 Replies)
Discussion started by: scorp_rahul23
4 Replies

9. UNIX for Dummies Questions & Answers

Capturing some data from a file into a variable

I have a file with some values in a tab delimted format Eg: 'test' contains: a<tab>b<tab>c<tab>Trk_12345678 now i need to capture this value 'Trk_12345678' into a variable say 'x' and append that value of 12345678 to 12345679 and store is back to a new 'test1' file as : 'test1'... (11 Replies)
Discussion started by: shiroh_1982
11 Replies

10. Shell Programming and Scripting

Capturing previous date in UNIX

Hi All, Hope you can help me out here...This is what I'm doing: % date '+%y.%m.%d' 05.03.05 How can I tweak this so that it gives me the PREVIOUS date, more specifically: 05.03.04 Hope you all can help. Thanks!!! Vince (3 Replies)
Discussion started by: tomeldan
3 Replies
Login or Register to Ask a Question
Traceroute(3pm) 					User Contributed Perl Documentation					   Traceroute(3pm)

NAME
Net::Traceroute - traceroute(1) functionality in perl SYNOPSIS
use Net::Traceroute; $tr = Net::Traceroute->new(host => "life.ai.mit.edu"); if($tr->found) { my $hops = $tr->hops; if($hops > 1) { print "Router was " . $tr->hop_query_host($tr->hops - 1, 0) . " "; } } DESCRIPTION
This module implements a parser for various traceroute implementations. At present, it can parse most LBL traceroute derivatives used on typical unixes, and the traceroute of cisco IOS. Traceroutes known not to be supported include that of Microsoft Windows and HP-UX. This module has two basic modes of operation, one, where it will run traceroute for you, and the other where you provide text from previously runing traceroute to parse. OVERVIEW
A new Net::Traceroute object must be created with the new method. Depending on exactly how the constructor is invoked, it may perform some tracing and/or parsing actions immediately, or it may return a "template" object that can be used to set parameters for several subsequent traceroutes. Methods are available for accessing information about a given traceroute attempt. There are also methods that view/modify the options that are passed to the object's constructor. To trace a route, UDP packets are sent with a small TTL (time-to-live) field in an attempt to get intervening routers to generate ICMP TIME_EXCEEDED messages. CONSTRUCTOR AND CLONING
$obj = Net::Traceroute->new([base_port => $base_port,] [debug => $debuglvl,] [max_ttl => $max_ttl,] [host => $host,] [text => $text,] [queries => $queries,] [query_timeout => $query_timeout,] [timeout => $timeout,] [source_address => $srcaddr,] [packetlen => $packetlen,] [trace_program => $program,] [no_fragment => $nofrag,] [use_icmp => $useicmp,]); $frob = $obj->clone([options]); This is the constructor for a new Net::Traceroute object. If given "host", it will immediately perform the traceroute. If given "text", it will parse that text as traceroute output. Given an existing Net::Traceroute object $obj as a template, you can call $obj->clone() with the usual constructor parameters. The same rules apply about defining host; that is, traceroute will be run if it is defined, or text will be parsed. You can always pass "host =" undef, text => undef> to clone. Possible options are: host - A host to traceroute to. If you don't set this, you get a Traceroute object with no traceroute data in it. The module always uses IP addresses internally and will attempt to lookup host names via inet_aton. text - Output from a previously run traceroute. If set, and host isn't, the given text will be parsed. base_port - Base port number to use for the UDP queries. Traceroute assumes that nothing is listening to port "base_port" to "base_port + (nhops - 1)" where nhops is the number of hops required to reach the destination address. Default is what the system traceroute uses (normally 33434). "Traceroute"'s "-p" option. debuglvl - A number indicating how verbose debug information should be. Please include debug=>9 output in bug reports. max_ttl - Maximum number of hops to try before giving up. Default is what the system traceroute uses (normally 30). "Traceroute"'s "-m" option. queries - Number of times to send a query for a given hop. Defaults to whatever the system traceroute uses (3 for most traceroutes). "Traceroute"'s "-q" option. query_timeout - How many seconds to wait for a response to each query sent. Uses the system traceroute's default value of 5 if unspecified. "Traceroute"'s "-w" option. timeout - Maximum time, in seconds, to wait for the traceroute to complete. If not specified, the traceroute will not return until the host has been reached, or traceroute counts to infinity ("max_ttl" * "queries" * "query_timeout"). Note that this option is implemented by Net::Traceroute, not the underlying traceroute command. source_address - Select the source address that traceroute wil use. packetlen - Length of packets to use. Traceroute tries to make the IP packet exactly this long. trace_program - Name of the traceroute program. Defaults to traceroute. You can pass traceroute6 to do IPv6 traceroutes. no_fragment - Set the IP don't fragment bit. Some traceroute programs will perform path mtu discovery with this option. use_icmp - Request that traceroute perform probes with ICMP echo packets, rather than UDP. METHODS
traceroute Run system traceroute, and parse the results. Will fill in the rest of the object for informational queries. parse Parse the previously provided "text", filling in the rest of the object for queries. Controlling traceroute invocation Each of these methods return the current value of the option specified by the corresponding constructor option. They will set the object's instance variable to the given value if one is provided. Changing an instance variable will only affect newly performed traceroutes. Setting a different value on a traceroute object that has already performed a trace has no effect. See the constructor documentation for information about methods that aren't documented here. base_port([PORT]) max_ttl([PORT]) queries([QUERIES]) query_timeout([TIMEOUT]) host([HOST]) text([TEXT]) timeout([TIMEOUT]) source_address([SRC]) packetlen([LEN]) trace_program([PROGRAM]) no_fragment([PROGRAM]) Obtaining information about a Trace These methods return information about a traceroute that has already been performed. Any of the methods in this section that return a count of something or want an Nth type count to identify something employ one based counting. stat Returns the status of a given traceroute object. One of TRACEROUTE_OK, TRACEROUTE_TIMEOUT, or TRACEROUTE_UNKNOWN (each defined as an integer). TRACEROUTE_OK will only be returned if the host was actually reachable. found Attempt to return 1 if the host was found, undef otherwise. This test is a poor heuristic, and will frequently give wrong answers. pathmtu If your traceroute supports MTU discovery, this method will return the MTU in some circumstances. You must set no_fragment, and must use a packetlen larger than the path mtu for this to be set. hops Returns the number of hops that it took to reach the host. hop_queries(HOP) Returns the number of queries that were sent for a given hop. This should normally be the same for every query. hop_query_stat(HOP, QUERY) Return the status of the given HOP's QUERY. The return status can be one of the following (each of these is actually an integer constant function defined in Net::Traceroute's export list): QUERY can be zero, in which case the first succesful query will be returned. TRACEROUTE_OK Reached the host, no problems. TRACEROUTE_TIMEOUT This query timed out. TRACEROUTE_UNKNOWN Your guess is as good as mine. Shouldn't happen too often. TRACEROUTE_UNREACH_NET This hop returned an ICMP Network Unreachable. TRACEROUTE_UNREACH_HOST This hop returned an ICMP Host Unreachable. TRACEROUTE_UNREACH_PROTO This hop returned an ICMP Protocol unreachable. TRACEROUTE_UNREACH_PORT Use in cisco and traceroute6 parsing. In cisco, "!U", in traceroute6, a "!". TRACEROUTE_UNREACH_ADDR This hop returned an ICMP6 address unreachable. TRACEROUTE_UNREACH_NEEDFRAG Indicates that you can't reach this host without fragmenting your packet further. Shouldn't happen in regular use. TRACEROUTE_UNREACH_SRCFAIL A source routed packet was rejected for some reason. Shouldn't happen. TRACEROUTE_UNREACH_FILTER_PROHIB A firewall or similar device has decreed that your traffic is disallowed by administrative action. Suspect sheer, raving paranoia. TRACEROUTE_BSDBUG The destination machine appears to exhibit the 4.[23]BSD time exceeded bug. TRACEROUTE_SOURCE_QUENCH Some machine has generated an ICMP Source Quench message, asking you to slow down. TRACEROUTE_INTERRUPTED "User interrupted test". Cisco's traceroute does this. Its unclear how to produce it. hop_query_host(HOP, QUERY) Return the dotted quad IP address of the host that responded to HOP's QUERY. QUERY can be zero, in which case the first succesful query will be returned. hop_query_time(HOP, QUERY) Return the round trip time associated with the given HOP's query. If your system's traceroute supports fractional second timing, so will Net::Traceroute. QUERY can be zero, in which case the first succesful query will be returned. CLONING SUPPORT BEFORE 1.04 Net::Traceroute Versions before 1.04 used new to clone objects. This has been deprecated in favor of the clone() method. If you have code of the form: my $template = Net::Traceroute->new(); my $tr = $template->new(host => "localhost"); You need to change the $template->new to $template->clone. This behavior was changed because it interfered with subclassing. BUGS
Net::Traceroute parses the output of the system traceroute command. As such, it may not work on your system. Support for more traceroute outputs (e.g. Windows, HPUX) could be done, although currently the code assumes there is "One true traceroute". The actual functionality of traceroute could also be implemented natively in perl or linked in from a C library. Versions prior to 1.04 had some interface issues for subclassing. These issues have been addressed, but required a public interface change. If you were relying on the behavior of new to clone existing objects, your code needs to be fixed. SEE ALSO
traceroute(1) AUTHOR
Daniel Hagerty <hag@ai.mit.edu> COPYRIGHT
Copyright 1998, 1999 Massachusetts Institute of Technology Copyright 2000, 2001 Daniel Hagerty Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of M.I.T. not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. M.I.T. makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. perl v5.14.2 2012-05-13 Traceroute(3pm)