Linux: Detect if port is closed from command line

PHOTO EMBED

Mon Aug 29 2022 15:58:55 GMT+0000 (UTC)

Saved by @marcopinero #bash

#!/bin/bash
#exit

#detect if port 11111 is open, if not do action:

netstat -ln | grep ":11111 " 2>&1 > /dev/null

if [ $? -eq 1 ]; then
    echo "Port is closed. Doing action..."
fi
content_copyCOPY

Bash script to make action in case port is closed.