Console Telnet App help
-
Hi Guys, I am working on a console app which telnets to a linux server. Now this linux server ask for a username and password which i try to send via my code. Now everything works up until the SendKeys.SendWait() - it seems that the window does not react to the "Enter" command. I have tested this with some other telnet servers, which are not linux and they work. Any help or if any other work around are available I am open for anything. My issue is - I have a system built by ADP and would like to grab data from them and put it into my on db to process. However, their system is closed and the solution I came up with is to screen scrape what I need. If you guys know something alredy out there or can point in the write direction it would be great. Thanks ahead of time.
public string Login(string Username,string Password,int LoginTimeOutMs)
{
int oldTimeOutMs = TimeOutMs;
TimeOutMs = LoginTimeOutMs;
string s = Read();
while(s == "" )
s = Read();// s += Read(); Console.Write(s); if (!s.TrimEnd().EndsWith(":")) throw new Exception("Failed to connect : no login prompt"); Console.Write(Username); SendKeys.SendWait("{ENTER}");
-
Hi Guys, I am working on a console app which telnets to a linux server. Now this linux server ask for a username and password which i try to send via my code. Now everything works up until the SendKeys.SendWait() - it seems that the window does not react to the "Enter" command. I have tested this with some other telnet servers, which are not linux and they work. Any help or if any other work around are available I am open for anything. My issue is - I have a system built by ADP and would like to grab data from them and put it into my on db to process. However, their system is closed and the solution I came up with is to screen scrape what I need. If you guys know something alredy out there or can point in the write direction it would be great. Thanks ahead of time.
public string Login(string Username,string Password,int LoginTimeOutMs)
{
int oldTimeOutMs = TimeOutMs;
TimeOutMs = LoginTimeOutMs;
string s = Read();
while(s == "" )
s = Read();// s += Read(); Console.Write(s); if (!s.TrimEnd().EndsWith(":")) throw new Exception("Failed to connect : no login prompt"); Console.Write(Username); SendKeys.SendWait("{ENTER}");
Not sure I can help, but I wrote a telnet client to do similar stuff (connect to a SCO UNIX box and manipulate a third-party character-based application). I had to create a script language for it. A Windows Service would cobble up the necessary script and run it. A sample script to log onto a server, execute
ps -a
, and disconnect:<login:
@someserver
<Password:myusername
<TERM
mypassword
<$ps -a
$exitThe important bits are:
System.Net.Sockets.TcpClient
System.Net.Sockets.NetworkStream
Anyway, I didn't use SendKeys, I simply used Read and Write on the stream. I would have written an article on it, but the handling of telnet options isn't quite right. -
Hi Guys, I am working on a console app which telnets to a linux server. Now this linux server ask for a username and password which i try to send via my code. Now everything works up until the SendKeys.SendWait() - it seems that the window does not react to the "Enter" command. I have tested this with some other telnet servers, which are not linux and they work. Any help or if any other work around are available I am open for anything. My issue is - I have a system built by ADP and would like to grab data from them and put it into my on db to process. However, their system is closed and the solution I came up with is to screen scrape what I need. If you guys know something alredy out there or can point in the write direction it would be great. Thanks ahead of time.
public string Login(string Username,string Password,int LoginTimeOutMs)
{
int oldTimeOutMs = TimeOutMs;
TimeOutMs = LoginTimeOutMs;
string s = Read();
while(s == "" )
s = Read();// s += Read(); Console.Write(s); if (!s.TrimEnd().EndsWith(":")) throw new Exception("Failed to connect : no login prompt"); Console.Write(Username); SendKeys.SendWait("{ENTER}");
I am working on a similar project. (ADP) I have some code that may work for you. I am also having an issue. My problem is I have a form with a textbox and a button. I need to be able to fill out the textbox push the button and send the textbox string to the telnet-console application to perform the task. I have built the form and have found code for the telnet-console application. I can logon successfully and perform a download with the telnet-console code. My problem is having the form communicate and trigger the telnet-console application. I would appreciate any help you could give. Thank you, GerosDS