Sending commands and receiving data using Telnet and SSH

0 votes
asked Sep 12, 2014 by sujayghosh (360 points)
edited Sep 15, 2014


I would like to send commands and read back the data , using Telnet and SSH.

I have gone through the sample TelnetSimpleWinFormClient_CS.

But in my case , I would like to read the user id / password from the settings form ,and connect to the telet windows. Once the connection is successfully established, I shall be sending a telnet command, and would like to read the output. All the mentioned steps shall be done programtically, without any user intervention.

I could hide the telnet window by setting stcConsole.Visible = false. Is that the correct way.

Please let me know.

Thanks Sujay

1 Answer

0 votes
answered Sep 15, 2014 by Pavel Matyska (13,440 points)
edited Sep 15, 2014


Use VirtualTerminal class instead of TerminalControl. The VirtualTerminal is GUI-less class that have same capabilities as TerminalControl class. Then use Scripting property of VirtualTerminal class instance for sending commands and reading responses.

Please note that when you connect via SSH, there is Login method in the Ssh class API, but when you use Telnet, there is no Login method and you need to log in using opened Telnet connection (work as normal command and response).

Here you can read more about VirtualTerminal class and Scripting capabilities.

VirtualTerminal features page

Scripting features page

How to script Telnet authentication - sample code