can ping doing this?..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting can ping doing this?..
# 1  
Old 09-21-2008
can ping doing this?..

i have question about this problem,,

could i ping ip address with the range 192.168.1.1 - 192.168.2.200 ?

ip address begin from 192.168.1.1 until 192.168.2.200 ?
could ping (not fping) doing that?
# 2  
Old 09-21-2008
Ping does not accept ranges. You can script around it or find another tool.
# 3  
Old 09-21-2008
Perl easily does the job:
Code:
perl -e 'use Socket; for (my $i=unpack("N",inet_aton("192.168.1.1")); $i <= unpack("N",inet_aton("192.168.2.200")); $i++) { system "ping -c 1 " . inet_ntoa(pack("N", $i)) . "\n" }'

# 4  
Old 09-21-2008
Quote:
Originally Posted by redoubtable
Perl easily does the job:
Code:
perl -e 'use Socket; for (my $i=unpack("N",inet_aton("192.168.1.1")); $i <= unpack("N",inet_aton("192.168.2.200")); $i++) { system "ping -c 1 " . inet_ntoa(pack("N", $i)) . "\n" }'

okey thanks about the answer,,
could bash creating like upper(perl script)?...
# 5  
Old 09-21-2008
Yes with bash >= 3.0:

Code:
for ip in 192.168.1.{1..255} 192.168.2.{0..200}; do
  ping -c1 $ip
done

For shells that do not support brace expansion:

Code:
for j in 1_255 2_200; do
  [ ${j%_*} -eq 1 ] && i=1 || i=0
  while [ $i -le ${j#*_} ]; do
    ping -c1 192.168.${j%_*}.$i
    i=$(($i + 1))
  done
done


Last edited by radoulov; 09-21-2008 at 09:30 AM..
# 6  
Old 09-21-2008
Quote:
Originally Posted by radoulov
Yes with bash >= 3.0:

Code:
for ip in 192.168.1.{1..255} 192.168.2.{0..200}; do
  ping -c1 $ip
done

For shells that do not support brace expansion:

Code:
for j in 1_255 2_200; do
  [ ${j%_*} -eq 1 ] && i=1 || i=0
  while [ $i -le ${j#*_} ]; do
    ping -c1 192.168.${j%_*}.$i
    i=$(($i + 1))
  done
done

okey thanks a lot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

3. IP Networking

PING

I am unable to ping my remote server.My server is unable to ping the same. both are able to ping the gateway. both the ip's are on same network.i use a proxy tunnel on my remote server.Help if any clues. (6 Replies)
Discussion started by: oslbhavana
6 Replies

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

5. IP Networking

Can't Ping

I have an old MP-Ras Unix system. I have setup netowkring but am unable to ping any local network pcs or the default gateway. If i use the arp -a command I receive the correct mac address for all connected pcs but I cannot ping anything except the local address. Any help would be appreciative. ... (7 Replies)
Discussion started by: Rutgerncas
7 Replies

6. Linux

Not able to ping

Hi All, Need your help one more time. I am trying to ping a linux machine which is not responding to ping. However traceroute can reach the machine and I can log in to it by ssh. I have checked /proc/sys/net/ipv4/icmp_echo_ignore_all it is already set as "0". It is not happening in the... (1 Reply)
Discussion started by: ailnilanjan
1 Replies

7. UNIX for Dummies Questions & Answers

Ping

Hi , I have one system installed on Linux Red Hat 3.0. I have ip of system 3.156.168.*** and i want to ping some port that is on this IP which command i can do this? sam70 (1 Reply)
Discussion started by: sam70
1 Replies

8. AIX

ping

We can ping out but the return never comes back even to localhost ping localhost PING loopback: (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0 ms it just sits there.... any ideas, any files to check (1 Reply)
Discussion started by: csaunders
1 Replies

9. UNIX for Dummies Questions & Answers

ping

Hi there hope list can help I'm looking for a command that does the following lets say i ping a server 00.00.000.00 and this server is up and running how do i get the ping command to return a UP or a Down meaning if the command is true do this if the command is False do this ... (2 Replies)
Discussion started by: nemex
2 Replies

10. IP Networking

About Ping

Hi, When I pinged a machin, I got to be seen a different kind of reply from that machine. This is as below : "Reply from 136.128.11.116: Source quench received." Which I felt like an un-usual message. So what does this mean. Regards & Thanks in advance. Vishwa. (4 Replies)
Discussion started by: S.Vishwanath
4 Replies
Login or Register to Ask a Question