I have simple script which show me if connection between server is working, problem is that now I have multiple number of servers which I want to check and I don't want to check one by one, would be good to add list of servers into file and script will be check each row in file. Anyone can help to extend script with loop
SERVER=$1
PORT=$2
nc -z -v -G5 $SERVER $PORT &> /dev/null
result1=$?
if [ "$result1" != 0 ]; then
echo port $PORT is closed on $SERVER
else
echo port $PORT is open on $SERVER
fi
ansiblein ad-hoc mode