1

I want to verify connection between 600+ WIN Servers using only telnet command. So I wrote a simple bat file with...

echo exit | telnet WINServer1 xx

echo exit | telnet WINServer2 xx

echo exit | telnet WINServer3 xx

Then I run the file in cmd.

C:\>test.bat > result.text

The problem is result.txt showed only the command in the bat file.

C:>echo quit | telnet WINServer1 xx

C:>echo quit | telnet WINServer1 xx

C:>echo quit | telnet WINServer1 xx

What I expected was all output result whether the connections success or not like...

C:>echo exit | telnet WINServer1 xx Connecting To server...Could not open connection to the host, on port xx: Connect failed

C:>echo exit | telnet WINServer2 xx SSH-x.x-OpenSSH_x.x

Protocol mismatch.

Connection to host lost.

C:>echo exit | telnet WINServer3 xx SSH-x.x-OpenSSH_x.x

Protocol mismatch.

Connection to host lost.

Is there any way to export all output that show up on cmd? It is prohibited to install any other utility or program on the servers.

Sal
  • 11
  • 1
  • use `@echo off` at beginning of the `bat` file, and set errorlevel, [see](http://stackoverflow.com/a/14279052/1484621) for more – Yu Jiaao Mar 23 '17 at 11:41
  • If the output from telnet is on the error stream you should append `2>&1` to your run command. –  Mar 23 '17 at 12:47

0 Answers0