ping loop


 
Thread Tools Search this Thread
Special Forums IP Networking ping loop
# 1  
Old 04-11-2007
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
# 2  
Old 04-11-2007
Code:
#!/bin/bash
for i in `sec 0 255`; do 
    ping -c 1 $i >/dev/null 2>&1 
    if [ "$?" = "0" ]; then 
echo -n "up" 
else echo -n "down" 
    fi
done

Something like that, that's the logic.
EDIT : Actually, there is written one
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Programming

Ping test sends mail when ping fails

help with bash script! im am working on this script to make sure my server will stay online, so i made this script.. HOSTS="192.168.138.155" COUNT=4 pingtest(){ for myhost in "$@" do ping -c "$COUNT" "$myhost" &&return 1 done return 0 } if pingtest $HOSTS #100% failed... (4 Replies)
Discussion started by: mort3924
4 Replies

3. Shell Programming and Scripting

awk loop using array:wish to store array values from loop for use outside loop

Here's my code: awk -F '' 'NR==FNR { if (/time/ && $5>10) A=$2" "$3":"$4":"($5-01) else if (/time/ && $5<01) A=$2" "$3":"$4-01":"(59-$5) else if (/time/ && $5<=10) A=$2" "$3":"$4":0"($5-01) else if (/close/) { B=0 n1=n2; ... (2 Replies)
Discussion started by: klane
2 Replies

4. Shell Programming and Scripting

How to get reason for ping failure using perls Net::Ping->new("icmp");?

Hi I am using perl to ping a list of nodes - with script below : $p = Net::Ping->new("icmp"); if ($p->ping($host,1)){ print "$host is alive.\n"; } else { print "$host is unreacheable.\n"; } $p->close();... (4 Replies)
Discussion started by: tavanagh
4 Replies

5. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

6. Shell Programming and Scripting

Animation Ping on Solaris Like Cisco Ping

Hi, I develop simple animation ping script on Solaris Platform. It is like Cisco ping. Examples and source code are below. bash-3.00$ gokcell 152.155.180.8 30 Sending 30 Ping Packets to 152.155.180.8 !!!!!!!!!!!!!.!!!!!!!!!!!!!!!. % 93.33 success... % 6.66 packet loss...... (1 Reply)
Discussion started by: gokcell
1 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

Ping inside FOR loop

Hello, I'm trying to write (my own primitive) traceroute command that would write out all IPs that packets are hoping through. :) So I've put the ping command inside a for loop #!/bin/bash domain=${1-www.google.com}; #If no argument, then do www.google.com. for ((i=1; i<=30; i++)) #... (9 Replies)
Discussion started by: courteous
9 Replies

9. 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

10. 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
Login or Register to Ask a Question