1848854 Members
8135 Online
104038 Solutions
New Discussion

Check zone ip

 
SOLVED
Go to solution
maxpayne
Occasional Contributor

Check zone ip

Hi,

In server A, I have a script that ping ip 10.30.11.209.
If the ip is up, it will show 10.30.11.209 is alive if not it will show unknown host 10.30.11.209. The input of the script will be in ip.txt

In server B, I need a script that can ftp server A and get the ip.txt. If the content show unknown host, it will then send an sms alert.
1 REPLY 1
Peter Godron
Honored Contributor
Solution

Re: Check zone ip

Hi,
something like:
Server A:
#/usr/bin/sh
rm out.txt
while read ip
do
ping $ip -n 1 > /dev/null 2>&1
status=$?
if [ $status -ne 0 ]
then
echo "$ip is alive" >> out.txt
else
echo "Unknown host $ip" >> out.txt
fi
done < ip.txt

Server B:
ftp -n ServerA << EOF
user id passwd
get out.txt
bye
EOF

count=`grep Unknown out.txt | wc -l`
if [ $count -gt 0 ]
then
mailx
fi