what do you expect it to return w/o the nexec ?
what are you trying to accomplish here ?
the telnet connect is going to hang for some time before it gets closed and then return back to the telnet prompt, requiring user interaction... so it's not a great command to run via nexec.
1 of 1 people found this helpful
You cannot do this if the remote host is Windows as it executes a separate process to run telnet, Linux/UNIX is fine.
There are other options if it is a remote Windows host
Could you please let me know how to achieve it using remote Windows host.
If you have remote Windows 2003 systems, you can use netsh diag.
nexec host_name netsh diag connect iphost target_host target_port
Unfortunately, Microsoft removed this from later versions of Windows (no idea why) so you have to use an external program/script that needs to be distributed to the target system. Portqry is a good option, or if you have Perl installed on Windows servers a simple script can be used.
I will see if I can make a one line Powershell test that can be used without distributing anything
To do this with Powershell
nexec host_name powershell -InputFormat none -command "(new-object Net.Sockets.TcpClient).Connect('target_host', target_port)"
The response isn't great - so returns nothing if successful or several lines of errors if unsuccessful, but can be used without distributing anything