📜  ping 一个端口 linux - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:50:53.137000             🧑  作者: Mango

代码示例2
# Use the below command in your terminal
# No requirments are needed
(echo >/dev/tcp/{host}/{port}) &>/dev/null && echo "open" || echo "close"

# An example below
(echo >/dev/tcp/10.20.20.21/27017) &>/dev/null && echo "open" || echo "close"

# if open then it will return "open"
# if closed then it will return "close"
# if you can't connect to it then it will freeze, use ctrl+c