#! /bin/bash port=22 for i in `cat $1` do ping -c 2 $i >/dev/null 2>&1 if [ $? -eq 0 ];then echo -e "\033[32m${i} is up\033[0m" echo $i >> ip_up.txt ssh $i uptime if [ $? -eq 0 ];then echo -e "\033[32m ip: ${i} port: ${port} is UP!\033[0m" echo "$i $port" >> ip_port_up.txt else echo -e "\033[31m ip: ${i} port: ${port} is DOWN!\033[0m" fi else echo -e "\033[31m${i} is down\033[0m" echo "$i $port" >> ip_port_down.txt echo $i >> ip_down.txt fi done