Clayton Bench
Clayton Bench

Reputation: 55

Sending Control-N and <CR><LF> via telnet using C#

I am currently using minimalistic Telnet from CodeProject and am having trouble sending the correct output to my telnet device. Essentially I am trying to automate the gathering of config data from Netopia DSL modems using this process. I am able to read the welcome screen of the netopia telnet interface just fine however I can not get any further.

The process manually goes like this: 1) Telnet to device ip 2) A welcome screen is displayed. 3) While on the welcome screen, press Control-N 4) Presented with a # prompt 5) sh config would print the config file to the screen.

Any help is very much appreciated.

Upvotes: 0

Views: 5196

Answers (2)

Holystream
Holystream

Reputation: 972

var login = "Login"+Environment.NewLine; // add carriage return at the end of text
var password = "Password" +Environment.NewLine;
telnetComponent.Send(login);
telnetComponent.Send(password);

Upvotes: 1

Andee
Andee

Reputation: 793

These are ascii codes.

char ctrln = (char)0x0E;
char cr = '\r';
char lf = '\n';

I've not tested the ctrl+n one but the other two should work.

Upvotes: 1

Related Questions