How do I check if a port is consistently alive? For example, I could use
ping 192.168.1.1 -t > results.txt
This will ping 192.168.1.1 continuously so that I could monitor it.
Is there an equivalent tool or command that I could use for this?
Currently I use telnet but sometimes the host disconnects it. I need a Windows solution.
You could use netcat if there is a Windows version - on Linux I use:
This returns 0 if the port is open. Run this in a loop for make it continuous.
If Powershell is available, see https://web.archive.org/web/20111102182913/http://poshcode.org/85 for an example.
Or use nmap from http://nmap.org , there is a windows version available.
nmap -p port host
or, for hosts not responding to ICMP requests,
nmap -P0 -p port host
You could use nping from nmap like:
where
-p
specifies the port to scan (here: 80). Furthermore you can use-H
for hiding sent packets, in favor of showing only replies.telnet
<host> <port>
will check remote<host>
for a TCP listener on<port>
.If you want to go with stock command line utils, then TELNET will connect to a port for you. On the flip side, if there is service responding, then TELNET may 'hang' while waiting for you to supply the escape command sequence.
If you're open to installing new command line utils, then PaPing works as you want. It's cross platform, and there is a Windows installer available.
Edited: Download nmap command line tools from nmap.org, there you will find ncat. Copy and paste this text and to text editor and save as .BAT-file