簡體   English   中英

如何使用Windows批處理文件檢查端口8086是否正在偵聽

[英]how to check if port 8086 is listening, using a windows batch file

需要使用批處理文件檢查進程是否正在運行以及正在使用的端口(8086和8085)是否處於偵聽狀態

netstat /o /a | find /i "listening" | find ":8086" >nul 2>nul && (
   echo 8086 is open
) || (
  echo 8086 is Not open
)
netstat -o -n -a | findstr 8086

if %ERRORLEVEL% equ 0 goto FOUND

echo port not found

goto FIN

:FOUND

echo port found

:FIN

注意:如果找不到項目,則FINDSTR將返回%ERRORLEVEL%> 0(如果找到項目),則FINDSTR將返回%ERRORLEVEL%= 0

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM