I put this together to search for unused IP addresses on a router. It's run as a Bash Command on OSX 10.9. Basically the user inputs the router address' IP range to sweep. 'jot' spits out a list of IP addresses based on that input and each one of those gets pinged. The output looks like this (tab delimitated):
xx.xxx.xx.xx Used name.domain.com
xx.xxx.xx.xx Used No Domain
xx.xxx.xx.xx Not_used
I was hoping to get help on 2 topics:
1. How can I manage error handling in the user input fields?
The first call to the user must only contain the first three quadrants of the router address: xx.xxx.xx(x). If I can just have it verify the input is numbers only with no more/less than 3 periods, that is sufficient
The last two calls are the low/high range inputs for the forth quadrant of the IP address which should be no more than 3 numbers (only numbers).
if entered incorrectly I would really like it to loop around and re-ask the user for that same input.
2. To exit, I press 'ctrl + c' but it requires I press it like 20 times before it breaks the actual process. I'm guessing I'm just breaking that instance of the while loop and it's moving onto the next line. Is there a more elegant way to do this without closing the window?
Any insight is appreciated. If there are any parts that can be streamlined below, let me know.
Last edited by sudo; 05-21-2014 at 06:30 PM..
Reason: typo
---------- Post updated at 02:13 PM ---------- Previous update was at 02:09 PM ----------
Or if your happy to use grep to validate, and your grep supports Extended REs (-E option).
You could replace the if with the following for full validation:
For a single value 1-255 you have a number of choices but I like:
Last edited by Chubler_XL; 05-22-2014 at 01:21 AM..
This User Gave Thanks to Chubler_XL For This Post:
---------- Post updated at 02:13 PM ---------- Previous update was at 02:09 PM ----------
Or if your happy to use grep to validate, and your grep supports Extended REs (-E option).
You could replace the if with the following for full validation:
For a single value 1-255 you have a number of choices but I like:
That function is great. I see the value defined by the user can can called by using $REPLY later on in the script. Is there a way I can create another variable?
The reason I ask, I want to build that function for all 3 user input fields- so $REPLY does't work for my variable. I need specific names such as PT1ADD, PT2ADD, and PT3ADD.
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)
This is a small program as a tester for a basic sweep generator for bandwidth testing of AudioScope.sh.
This DEMO is only capable of 4KHz down to about 85Hz and back due to the low bit rate, but it is proof of concept for a much wider variant using a much higher bit rate.
The file generated... (4 Replies)
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)
SHAME, that's all that I'm felling right now, however I'm not finding PING or either tracert in my box (Solaris 10).
1) Yes my PATH does have /usr/bin /usr/sbin
# echo $PATH
/opt/csw:/usr/bin:/sbin:/usr/sbin:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin:/opt/csw/gcc2/bin:/opt/csw/bin
2) If I... (1 Reply)
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)
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)
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)
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)
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)