In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to use the bat script in Windows to determine whether the port is available, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
Environment:
A server uses portmap for port forwarding, but this program often kneels and needs to be restarted manually
The solution is as follows:
Monitor the program port through bat, and restart automatically when the port is unavailable. If the port is available, the telnet process will come out. If the port is not available, the telnet process will not appear. Determine whether the port is available according to the existence of the process, because if telnet is open, it will jump to the window directly without echo, so enable a new window when you need telnet.
Method two
@ echo offtitle PortMap Survival Monitoring! : againset ip=127.0.0.1set port=8080start telnet.exe% ip%% port%ping-7 127.0.0.1 > nulltasklist | findstr / I "telnet.exe" > nulif ERRORLEVEL 1 (goto err) else (goto ok): errtasklist | findstr-I "portmap.exe" if ERRORLEVEL 1 (start "" D:\ PortMap1.6\ PortMap.exe ") else (taskkill / F-IM PortMap.exe & start"D:\ PortMap1.6\ PortMap.exe"): oktaskkill / F-IM "telnet.exe "> > nulecho PortMap Services is running Date:~0,4%-%Date:~5,2%-%Date:~8,2%% Time:~0,2%:%Time:~3,2%ping-n 300 127.0.0.1 > nulgoto again
Method two
@ echo offtitle PortMap Survival Monitoring! : againset ip=127.0.0.1set port=8080netstat-ano | findstr% ip%:%port% | findstr-i ESTABLISHEDif ERRORLEVEL 1 (goto err) else (goto ok): errtasklist | findstr-I "portmap.exe" if ERRORLEVEL 1 (start "D:\ PortMap1.6\ PortMap.exe") else (taskkill / F-IM PortMap.exe & start "" D:\ PortMap1.6\ PortMap.exe "): okecho PortMap Services is running% Date:~0,4%-%Date:~5,2%-%Date:~8,2%% Time:~0,2 %:% Time:~3,2%ping-n 300 127.0.0.1 > nulgoto again's answer to the question about how to use bat scripts in Windows to determine whether a port is available is shared here. I hope the above content can help you to a certain extent, if you still have a lot of doubts to be solved, you can follow the industry information channel to learn more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.