Sponsored Content
Full Discussion: Ping inside FOR loop
Top Forums Shell Programming and Scripting Ping inside FOR loop Post 302477468 by courteous on Sunday 5th of December 2010 10:34:56 AM
Old 12-05-2010
Quote:
Originally Posted by scottn
You might also want to use -c?
First, thank you for the reply.
  1. I've seen other scripts that used, say, -c 2, but I don't (really) understand why (yes, I looked at man ping).

    In ICMP's first 8 bits I'll be getting #11 (TTL expired) and not #0 (ECHO_REPLY), which is what switch -c is referring to. Well, what is wrong with my "logic"?
    ADD: Should I use -c 1 for each hop on the way, is that right?
  2. How to find the right maximum TTL number? Smilie for example, pinging google.com it takes 14 hops. So, if I do the for loop 30 times, the last 16 IPs are all (almost) the same.

Last edited by courteous; 12-05-2010 at 11:46 AM..
 

10 More Discussions You Might Find Interesting

1. IP Networking

ping loop

i need to write a script that can loop through ej.192.162.0.0 to 192.162.0.256 find the ones that are connected and the ones not connected write the name , ip address and connection status of each one in a file to later use it in perl to create a web page with the information thanks guys (1 Reply)
Discussion started by: djbilly
1 Replies

2. Shell Programming and Scripting

help: infinant loop script - host ping test

need to check on some hosts and send an email if there status changes I wanna put together a script in bash that will allow me to check the up/down state of a single host via ping i want it to run in a continuous loop so I can just fire the script and forget about it(dont want cron to drive... (2 Replies)
Discussion started by: zeekblack
2 Replies

3. Shell Programming and Scripting

variable inside variable inside loop headache

Hi Gurus I have a file called /tmp/CMDB which looks like this serial: 0623AN1208 hostname: server1 model: x4100 assetID: 1234 I am writing a for loop that will go through this file line by line creating a variable of itself. Using the first iteration of the loop (i.e. the first line) as... (6 Replies)
Discussion started by: hcclnoodles
6 Replies

4. Shell Programming and Scripting

Using variables created sequentially in a loop while still inside of the loop [bash]

I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends. As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

5. Shell Programming and Scripting

Using 'su' inside a loop

Hi, I am using su within a for loop. As you might expect, it prompts for password during each loop execution. Here is my piece of code: for i in $LIST do if then DATABASE=`echo $i | awk -F "|" '{ print $1 }'` USER_ID=`echo $i | awk -F "|" '{ print $2 }'` su - apstage -c... (1 Reply)
Discussion started by: sugan
1 Replies

6. Shell Programming and Scripting

BASH loop inside a loop question

Hi all Sorry for the basic question, but i am writing a shell script to get around a slightly flaky binary that ships with one of our servers. This particular utility randomly generates the correct information and could work first time or may work on the 12th or 100th attempt etc !.... (4 Replies)
Discussion started by: rethink
4 Replies

7. Programming

Perl Ping Loop

Hi All i have an issue with ping, we are using dhcp and so if the machine has been offline and i ping it, i get " ping: unknown host <hostname> is there a way i can stick a loop somewhere so it would keep trying when it got the unknown host error and then when the machine came back online... (2 Replies)
Discussion started by: ab52
2 Replies

8. Shell Programming and Scripting

If inside If loop

Hi All, Below is the very simple code snippet but it si giving me syntax error #!/bin/bash #To ensure If JMS directory exists or not ServerName=$(hostname) #To ensure If JMS directory exists or not echo $ServerName if ; then echo "Inside First If" if ; then echo 'JMS... (4 Replies)
Discussion started by: sharsour
4 Replies

9. UNIX for Dummies Questions & Answers

Write a while loop inside for loop?

I'm taking a unix class and need to countdown to 0 from whatever number the user inputs. I know how to do this with a while or until loop but using the for loop is throwing me off.... I know I can use an if-then statement in my for loop but can I include a while loop in my for loop? (3 Replies)
Discussion started by: xxhieixx
3 Replies

10. IP Networking

Loop in /24 Subnet, No ping beyond .1 and .2

Running 3650 switch. I have this odd issue where I cannot get 4 new Centos 7 boxes pinging out on public IPs (nor pinging in), only gateway .1 and first public IP .2 This is what I see, which doesn't look normal. How do I fix this? The server itself is configured fine (Centos 7) # cat... (0 Replies)
Discussion started by: Bashed
0 Replies
SC_ANALYSIS_DUMP(1)					    BSD General Commands Manual 				       SC_ANALYSIS_DUMP(1)

NAME
sc_analysis_dump -- dump of traceroute data in a format that is easily parsed. SYNOPSIS
sc_analysis_dump [-cCdeghHiloprst] [-D debug-count] [-G geo-server] [-S skip-count] [file ...] DESCRIPTION
The sc_analysis_dump utility provides a dump of traceroute data in a format that is easily parsed by scripts. Each line output contains a summary of a single trace, and includes the interfaces visited and the delay of each response. The output format is identical to that of sk_analysis_dump from CAIDA, except that it uses the scamper file API to read both arts++ files produced by skitter and warts files produced by scamper. The options are as follows: -c disables printing the cycle number in each line of output. -C disables printing the comments about the output at the top of the output. -d disables printing the destination address in each line of output. -D debug-count for each input file stop reading after the specified number of traces. -e adds the response from the destination to each line of output. -g use geographical data from netacuity. Not all builds of sc_analysis_dump support this option. -G geo-server specifies the name of the netacuity server to use. -h prints a help message and then exits. -H disables printing the halt fields: why traceroute halted and data for that reason. -i disables printing the RTT to each hop, and how many tries were required. -l disables printing the list id in each line of output. -o prints each line of output using the old format from sk_analysis_dump 1.0. -p disables print path data in each line of output. -r disables printing the data associated the response from a destination: the RTT, the TTL of the probe, and the TTL of the response. -s disables printing the source IP address in each line of output. -S skip-count skips the defined number of traces from each input file. -t disables printing the timestamp of when the traceroute began. OUTPUT
There is one trace per line. Fields are separated by a tab character. The output is structured into header fields (2 to 6), reply fields (7 to 10) corresponding to the response received from the destination, halt fields (11 and 12), and hop fields (beginning at index 13). 1. Key Indicates the type of line and determines the meaning of the remaining fields. This will always be 'T' for an IP trace. 2. Source Source IP of skitter/scamper monitor performing the trace. 3. Destination Destination IP being traced. 4. ListId ID of the destination list containing this destination address. This value will be zero if no list ID was provided. A ListId is a 32 bit unsigned integer. 5. CycleId ID of current probing cycle. A cycle is a single run through a given list. A CycleId is a 32 bit unsigned integer. For skitter traces, cycle IDs will be equal to or slightly earlier than the timestamp of the first trace in each cycle. There is no standard interpretation for scamper cycle IDs. This value will be zero if no cycle ID was provided. 6. Timestamp Timestamp when trace began to this destination. 7. DestReplied Whether a response from the destination was received. The character R is printed if a reply was received. The character N is printed if no reply was received. Since skitter sends a packet with a TTL of 255 when it halts probing, it is still possible for the final destination to send a reply and for the HaltReasonData (see below) to not equal no_halt. Note: scamper does not perform this last-ditch probing at TTL 255 by default. 8. DestRTT The RTT (ms) of first response packet from destination. This value is zero if DestReplied is N. 9. RequestTTL TTL set in request packet which elicited a response (echo reply) from the destination. This value is zero if DestReplied is N. 10. ReplyTTL TTL found in reply packet from destination. This value is zero if DestReplied is N. 11. HaltReason A single character corresponding to the reason, if any, why incremental probing stopped. S is printed if the destination was reached or there is no halt data. U is printed if an ICMP unreachable message was received. L is printed if a loop was detected. G is printed if the gaplimit was reached. 12. HaltReasonData Extra data about why probing halted. If HaltReason is S, the zero is output. If HaltReason is U, the ICMP code of the unreachable message is printed. If HaltReason is L, the length of the loop is printed. If HaltReason is G, the length of the gap is printed. 13. PathComplete Whether all hops to destination were found. C is printed if the trace is complete, all hops are found. I is printed if the trace is incomplete, at least one hop is missing (i.e., did not respond). 14. PerHopData Response data for each hop. If multiple IP addresses respond at the same hop, response data for each IP address are separated by semicolons: IP,RTT,numTries (for only one responding IP) IP,RTT,numTries;IP,RTT,numTries;... (for multiple responding IPs) where IP is the IP address which sent a TTL expired packet, RTT is the RTT of the TTL expired packet, and numTries is the number of tries before a response was received from the TTL. This field has the value 'q' if there was no response at a hop. EXAMPLES
The command: sc_analysis_dump file1.warts file2.warts will decode and print the traceroute objects in file1.warts, followed by the traceroute objects in file2.warts. The command: gzcat file1.warts.gz | sc_analysis_dump will decode and print the traceroute objects in the uncompressed file supplied on stdin. SEE ALSO
scamper(1), sc_wartsdump(1) AUTHORS
sc_analysis_dump is written by Matthew Luckie <mjl@luckie.org.nz>. It is derived from CAIDA's sk_analysis_dump program and should behave in an identical manner. BSD
October 15, 2010 BSD
All times are GMT -4. The time now is 10:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy