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. connecting to telnet and executing perl script [modified]

connecting to telnet and executing perl script [modified]

Scheduled Pinned Locked Moved C#
perlcsharptoolshelp
12 Posts 4 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.
  • L Offline
    L Offline
    l laxmikant
    wrote on last edited by
    #1

    hi friends I have some perl scripts which are on unix machine. I need to connect to telnet and execute these perl scripts using C#. please help me for this... thanks

    modified on Wednesday, February 24, 2010 3:59 AM

    L P 4 Replies Last reply
    0
    • L l laxmikant

      hi friends I have some perl scripts which are on unix machine. I need to connect to telnet and execute these perl scripts using C#. please help me for this... thanks

      modified on Wednesday, February 24, 2010 3:59 AM

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Firstly what has this to do with C#? Secondly what is your problem in using telnet?

      txtspeak is the realm of 9 year old children, not developers. Christian Graus

      L 1 Reply Last reply
      0
      • L Lost User

        Firstly what has this to do with C#? Secondly what is your problem in using telnet?

        txtspeak is the realm of 9 year old children, not developers. Christian Graus

        L Offline
        L Offline
        l laxmikant
        wrote on last edited by
        #3

        firstly read the thread, i need to connect to telnet and execute the perl scripts which are on unix machine using C# i hope u will understand this

        P 1 Reply Last reply
        0
        • L l laxmikant

          firstly read the thread, i need to connect to telnet and execute the perl scripts which are on unix machine using C# i hope u will understand this

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          He's asking what you've done so far. What code have you got? What's not working?

          "WPF has many lovers. It's a veritable porn star!" - Josh Smith

          As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

          My blog | My articles | MoXAML PowerToys | Onyx

          L 1 Reply Last reply
          0
          • P Pete OHanlon

            He's asking what you've done so far. What code have you got? What's not working?

            "WPF has many lovers. It's a veritable porn star!" - Josh Smith

            As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

            My blog | My articles | MoXAML PowerToys | Onyx

            L Offline
            L Offline
            l laxmikant
            wrote on last edited by
            #5

            // code is as follow, it executes without any exception but nothing happens at unix and i get the response as ??% all time string message = "./mahesh/touch test_connection1"; Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Blocking = true; socket.Connect("10.111.16.199", 23); TelnetStream stream = new TelnetStream(socket); Byte[] data = System.Text.Encoding.ASCII.GetBytes(message); stream.Write(data, 0, data.Length); // String to store the response ASCII representation. String responseData = String.Empty; // Read the first batch of the TcpServer response bytes. Int32 bytes = stream.Read(data, 0, data.Length); responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes); Console.WriteLine("Received: {0}", responseData); // Close everything. stream.Close(); socket.Close();

            P P 2 Replies Last reply
            0
            • L l laxmikant

              // code is as follow, it executes without any exception but nothing happens at unix and i get the response as ??% all time string message = "./mahesh/touch test_connection1"; Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Blocking = true; socket.Connect("10.111.16.199", 23); TelnetStream stream = new TelnetStream(socket); Byte[] data = System.Text.Encoding.ASCII.GetBytes(message); stream.Write(data, 0, data.Length); // String to store the response ASCII representation. String responseData = String.Empty; // Read the first batch of the TcpServer response bytes. Int32 bytes = stream.Read(data, 0, data.Length); responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes); Console.WriteLine("Received: {0}", responseData); // Close everything. stream.Close(); socket.Close();

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              What happens if you telnet to this normally? Does it prompt you for credentials?

              "WPF has many lovers. It's a veritable porn star!" - Josh Smith

              As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

              My blog | My articles | MoXAML PowerToys | Onyx

              L 1 Reply Last reply
              0
              • P Pete OHanlon

                What happens if you telnet to this normally? Does it prompt you for credentials?

                "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                My blog | My articles | MoXAML PowerToys | Onyx

                L Offline
                L Offline
                l laxmikant
                wrote on last edited by
                #7

                thanks for reply.... it doesn't prompt for login..

                L 1 Reply Last reply
                0
                • L l laxmikant

                  thanks for reply.... it doesn't prompt for login..

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  l.laxmikant wrote:

                  it doesn't prompt for login.

                  Then something is wrong with your UNIX setup, telnet should always prompt for a login.

                  txtspeak is the realm of 9 year old children, not developers. Christian Graus

                  1 Reply Last reply
                  0
                  • L l laxmikant

                    hi friends I have some perl scripts which are on unix machine. I need to connect to telnet and execute these perl scripts using C#. please help me for this... thanks

                    modified on Wednesday, February 24, 2010 3:59 AM

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #9

                    I've had to telnet into Unix systems and run some automated stuff before. (Five years ago, with C# 1.0 and .net 1.1) I found a telnet client class somewhere, I'm not sure where, but probably not on CP. From that, I wrote my own and added the ability for it to execute command scripts -- with my own little scripting language. It worked just great with only a few minor problems. Unfortunately, my classes didn't get to a point where I felt I could write an article and publish them. I was actually working on that when I got laid off from that job. :^) Anyway, you need a telnet client class; just a socket won't do it. Does the current version of .net have a telnet client class? I haven't bothered to look. P.S. My Telnet client class wraps a TcpClient object.

                    modified on Wednesday, February 24, 2010 4:58 PM

                    1 Reply Last reply
                    0
                    • L l laxmikant

                      // code is as follow, it executes without any exception but nothing happens at unix and i get the response as ??% all time string message = "./mahesh/touch test_connection1"; Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Blocking = true; socket.Connect("10.111.16.199", 23); TelnetStream stream = new TelnetStream(socket); Byte[] data = System.Text.Encoding.ASCII.GetBytes(message); stream.Write(data, 0, data.Length); // String to store the response ASCII representation. String responseData = String.Empty; // Read the first batch of the TcpServer response bytes. Int32 bytes = stream.Read(data, 0, data.Length); responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes); Console.WriteLine("Received: {0}", responseData); // Close everything. stream.Close(); socket.Close();

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #10

                      l.laxmikant wrote:

                      TelnetStream

                      What namespace is it in?

                      1 Reply Last reply
                      0
                      • L l laxmikant

                        hi friends I have some perl scripts which are on unix machine. I need to connect to telnet and execute these perl scripts using C#. please help me for this... thanks

                        modified on Wednesday, February 24, 2010 3:59 AM

                        P Offline
                        P Offline
                        PIEBALDconsult
                        wrote on last edited by
                        #11

                        Have you gotten it working? I got back to looking at my code yesterday and found that it isn't broken so I may be publishing it soon. If you found another class that does it could you let me know so I can check it out too?

                        1 Reply Last reply
                        0
                        • L l laxmikant

                          hi friends I have some perl scripts which are on unix machine. I need to connect to telnet and execute these perl scripts using C#. please help me for this... thanks

                          modified on Wednesday, February 24, 2010 3:59 AM

                          P Offline
                          P Offline
                          PIEBALDconsult
                          wrote on last edited by
                          #12

                          Here[^] is my article on my TelnetSocket. Have a look and let me know what you think.

                          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