#!/bin/bash
ip=$1
if [ -z "$ip" ]; then
echo "U must enter ip as argument: $0 [ip]"
exit 1
fi
testip=`echo $ip |grep -E "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])[.]){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"`
if [ -z "$testip" ]; then
echo "Wrong ip adress"
exit 2
fi
ping -c 2 $ip 2>&1 >/dev/null
if [ $? -eq 0 ]; then
echo "$ip is UP"
else
echo "$ip is DOWN"
fi
exit 0
This is the script thet checks is the ip is up or down..
for exmp ./iptest.sh xxxx.xxxx.xxxx.xxxx
But i dont know how to make same script that reads ip adresses from a file.
for exmp if i have a file ip.txt,and there are like 5 adresses written inside,what do i need to add so my script reads the file and writes me down are the ips UP or down?
Thnx a lot
Last edited by DukeNuke2; 06-23-2013 at 05:45 PM..