What is the command to check a port?检测端口的命令是什么? #1143
-
For some reasons, I need to identify if a device is online by checking the status of a specified port instead of using the default ping method. The software has the functionality to check ports. So, can the default ping command be replaced with a command to check a specified port? If so, what is the command? 因为一些原因,我需要通过判断设备指定的端口状态来识别是否在线,而不是默认的ping,软件有检测端口的功能,那么能否把默认得到ping命令替换成检测指定端口的命令?如果可以,请问命令是什么? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You could use the following ping command: nc -z -w 1 <ip> <port>; exit $? Replace the ip and port. The command will |
Beta Was this translation helpful? Give feedback.
You could use the following ping command:
Replace the ip and port. The command will
exit 0
if port is open andexit 1
if closed.-w 1
sets a timeout of 1 second.