Chadrick Blog

bash script for checking rmate port is available or not

portnum=52698
result=$(echo <sudopassword> | sudo -S netstat -tulpn | grep $portnum | wc -l)
echo "\\n"
if \[ $result -eq 0 \]
then
    echo -e "\\e\[31m$portnum not available\\e\[0m"
else
    echo -e "\\e\[32m$portnum available\\e\[0m"
fi