Test from shell script if remote TCP port is open - BASH


function check_net_port ()
{
local ip=$1
local port=$2
exec 3> /dev/tcp/"$ip"/"$port"
if [ $? -eq 0 ]; then return 0; else return 1; fi
}