Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Console Telnet App help

Console Telnet App help

Scheduled Pinned Locked Moved C#
helpjavascriptdatabasesysadminlinux
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nit115
    wrote on last edited by
    #1

    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}");
    
    P G 2 Replies Last reply
    0
    • N nit115

      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}");
      
      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      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
      $exit

      The 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.

      1 Reply Last reply
      0
      • N nit115

        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}");
        
        G Offline
        G Offline
        GerosDS
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups