using cmd.exe as a telnet client

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Donnal Walter

    #1

    using cmd.exe as a telnet client

    Several months ago I tried using the telnet module (on Windows XP) to
    communicate with a proprietary host on our network. This was
    unsuccessful due to problems with "option negotiation", and I gave up on
    the project for a while. I still have need for this, however, so I
    recently started thinking about alternatives. I suppose I could dig deep
    enough into option negotiation to use the socket module (with telnet as
    a guide), but I am hoping to find a way to use fewer synapses.

    Using the Windows C:> prompt (cmd.exe) I can telnet into this host with
    no problems (the Windows telnet client performs option negotiation just
    fine). Is there a straightforward way of using os.popen() (or os.fork()
    or os.exec*() or os.wait*()) to connect to the host from Python via the
    Windows telnet client?

    Thanks,
    Donnal Walter
    Arkansas Children's Hospital


  • Grant Edwards

    #2
    Re: using cmd.exe as a telnet client

    On 2004-12-03, Donnal Walter <donnal@donnal. net> wrote:
    [color=blue]
    > Several months ago I tried using the telnet module (on Windows XP) to
    > communicate with a proprietary host on our network. This was
    > unsuccessful due to problems with "option negotiation", and I gave up on
    > the project for a while. I still have need for this, however, so I
    > recently started thinking about alternatives. I suppose I could dig deep
    > enough into option negotiation to use the socket module (with telnet as
    > a guide), but I am hoping to find a way to use fewer synapses.[/color]

    You don't have to start from scratch. The telnet module has
    hooks built-into it1 so that you can have it call your routines
    to handle option negotiation. I did it once to impliment some
    extra Telnet protocol features, and it wasn't difficult.

    --
    Grant Edwards grante Yow! How's the wife? Is
    at she at home enjoying
    visi.com capitalism?

    Comment

    • Donnal Walter

      #3
      Re: using cmd.exe as a telnet client

      Grant Edwards wrote:[color=blue]
      > You don't have to start from scratch. The telnet module has
      > hooks built-into it1 so that you can have it call your routines
      > to handle option negotiation. I did it once to impliment some
      > extra Telnet protocol features, and it wasn't difficult.[/color]

      Ok, you've inspired me to give it a try. First, I am assuming that you
      mean writing a custom callback function to send to
      Telnet.set_opti on_negotiation_ callback(callba ck). Or did you mean
      writing a subclass of Telnet? Can someone provide an example of a
      callback function that I might use as a template for writing mine?

      This is unfamiliar territory for me, but I tried to snoop a bit using
      ethereal (also new to me) and as near as I can tell, the options in
      question are:
      0, binary transmission
      1, echo
      3, suppress go ahead
      23, send location

      And it may be that not all of these are critical, but if so, I don't
      know how to tell which is which.

      Eyal Lotem wrote:[color=blue]
      > I think I have a much simpler solution for you guys..
      > Assuming you can run arbitrary code on the proprietary
      > server.[/color]

      Actually I cannot. The server runs a second-party information system,
      the primary access to which is third-party terminal emulator software
      that uses telnet connections. What I am trying to do is emulate this
      emulator. :-)
      [color=blue]
      > cmd.exe is not a command line program. It's a terminal (emulator).
      > You might be able to use the telnet program, though.[/color]

      Yes, I see that now. Thanks.
      [color=blue]
      > Before doing this,
      > I'd recommend looking at Twisted's telnet support (both
      > the version in 1.3 and the version that will be in 2.0),
      > which actually supports option negotiation in a
      > reasonable way.[/color]

      I've been wanting to get acquainted with Twisted for awhile now, so this
      might be a good time to do so. I think I will give Grant's idea a whirl,
      but if I get bogged down there, I will definitely look at Twisted's
      telnet support. BTW, do you know if Twisted's option negotiation uses a
      callback function? I might download it just to take a look, even if I
      don't use it directly.

      Thanks,
      Donnal Walter
      Arkansas Children's Hospital


      Comment

      • Donnal Walter

        #4
        Re: using cmd.exe as a telnet client

        Grant Edwards wrote:[color=blue]
        > You don't have to start from scratch. The telnet module has
        > hooks built-into it1 so that you can have it call your routines
        > to handle option negotiation. I did it once to impliment some
        > extra Telnet protocol features, and it wasn't difficult.[/color]

        Ok, you've inspired me to give it a try. First, I am assuming that you
        mean writing a custom callback function to send to
        Telnet.set_opti on_negotiation_ callback(callba ck). Or did you mean
        writing a subclass of Telnet? Can someone provide an example of a
        callback function that I might use as a template for writing mine?

        This is unfamiliar territory for me, but as near as I can tell, the
        options in question are:
        0, binary transmission
        1, echo
        3, suppress go ahead
        23, send location

        And it may be that not all of these are critical, but if so, I don't
        know how to tell which is which.

        Eyal Lotem wrote:[color=blue]
        > I think I have a much simpler solution for you guys..
        > Assuming you can run arbitrary code on the proprietary
        > server.[/color]

        Actually I cannot. The server runs a second-party information system,
        the primary access to which is third-party terminal emulator software
        that uses telnet connections. What I am trying to do is emulate this
        emulator. :-)

        Jp Calderone wrote:[color=blue]
        > cmd.exe is not a command line program. It's a terminal (emulator).
        > You might be able to use the telnet program, though.[/color]

        Yes, I see that now. Thanks.
        [color=blue]
        > Before doing this,
        > I'd recommend looking at Twisted's telnet support (both
        > the version in 1.3 and the version that will be in 2.0),
        > which actually supports option negotiation in a
        > reasonable way.[/color]

        I've been wanting to get acquainted with Twisted for awhile now, so this
        might be a good time to do so. I think I will give Grant's idea a whirl,
        but if I get bogged down there, I will definitely look at Twisted's
        telnet support. BTW, do you know if Twisted's option negotiation uses a
        callback function? I might download it just to take a look, even if I
        don't use it directly.

        Thanks,
        Donnal Walter
        Arkansas Children's Hospital


        Comment

        • Donnal Walter

          #5
          Re: using cmd.exe as a telnet client

          Grant Edwards wrote:[color=blue]
          > You don't have to start from scratch. The telnet module has
          > hooks built-into it1 so that you can have it call your routines
          > to handle option negotiation. I did it once to impliment some
          > extra Telnet protocol features, and it wasn't difficult.[/color]

          Ok, you've inspired me to give it a try. First, I am assuming that you
          mean writing a custom callback function to send to
          Telnet.set_opti on_negotiation_ callback(callba ck). Or did you mean
          writing a subclass of Telnet? Can someone provide an example of a
          callback function that I might use as a template for writing mine?

          This is unfamiliar territory for me, but as I can tell, the options in
          question are:
          0, binary transmission
          1, echo
          3, suppress go ahead
          23, send location

          And it may be that not all of these are critical, but if so, I don't
          know how to tell which is which.

          Eyal Lotem wrote:[color=blue]
          > I think I have a much simpler solution for you guys..
          > Assuming you can run arbitrary code on the proprietary
          > server.[/color]

          Actually I cannot. The server runs a second-party information system,
          the primary access to which is third-party terminal emulator software
          that uses telnet connections. What I am trying to do is emulate this
          emulator. :-)

          Jp Calderone wrote:[color=blue]
          > cmd.exe is not a command line program. It's a terminal (emulator).
          > You might be able to use the telnet program, though.[/color]

          Yes, I see that now. Thanks.
          [color=blue]
          > Before doing this,
          > I'd recommend looking at Twisted's telnet support (both
          > the version in 1.3 and the version that will be in 2.0),
          > which actually supports option negotiation in a
          > reasonable way.[/color]

          I've been wanting to get acquainted with Twisted for awhile now, so this
          might be a good time to do so. I think I will give Grant's idea a whirl,
          but if I get bogged down there, I will definitely look at Twisted's
          telnet support. BTW, do you know if Twisted's option negotiation uses a
          callback function? I might download it just to take a look, even if I
          don't use it directly.

          Thanks,
          Donnal Walter
          Arkansas Children's Hospital


          Comment

          • Grant Edwards

            #6
            Re: using cmd.exe as a telnet client

            On 2004-12-06, Donnal Walter <donnal@donnal. net> wrote:[color=blue]
            > Grant Edwards wrote:[color=green]
            > > You don't have to start from scratch. The telnet module has
            > > hooks built-into it1 so that you can have it call your routines
            > > to handle option negotiation. I did it once to impliment some
            > > extra Telnet protocol features, and it wasn't difficult.[/color]
            >
            > Ok, you've inspired me to give it a try. First, I am assuming
            > that you mean writing a custom callback function to send to
            > Telnet.set_opti on_negotiation_ callback(callba ck).[/color]

            Yes.
            [color=blue]
            > Or did you mean writing a subclass of Telnet?[/color]

            That depends. If you need to _impliment_ a feature in addition
            to doing the negotiation, then you may want to define a
            subclass -- though it may easier to just grab the source for
            telnetlib and add the feature.
            [color=blue]
            > Can someone provide an example of a callback function that I
            > might use as a template for writing mine?[/color]

            I've got a negotiation function at home I'll try to remember to
            post.
            [color=blue]
            > This is unfamiliar territory for me, but as near as I can tell, the
            > options in question are:
            > 0, binary transmission
            > 1, echo
            > 3, suppress go ahead
            > 23, send location
            >
            > And it may be that not all of these are critical, but if so, I
            > don't know how to tell which is which.[/color]

            That's the tricky part. :)

            I guess I'd "enable" negotiation of each of the features one at
            a time, and see what happens.

            --
            Grant Edwards grante Yow! Hey, I LIKE that
            at POINT!!
            visi.com

            Comment

            • Donnal Walter

              #7
              Re: using cmd.exe as a telnet client

              I wrote:[color=blue]
              > I've been wanting to get acquainted with Twisted for awhile
              > now, ... BTW, do you know if Twisted's option negotiation
              > uses a callback function? I might download it to take a look, ...[/color]

              Sorry I did not do this earlier, before I posted. It is obvious (now
              that I have downloaded it) that Twisted's Telnet implementation is based
              on its own Protocol base class (nice design). The only documentation I
              have been able to find, however, is in the protocols/telnet module
              itself. It is still not immediately obvious (to me) how to use the iac*
              methods to negotiate these options. Any help is much appreciated.

              (I've not given up on writing my own funtion for Python's telnetlib, but
              I'm trying to keep all my options open. Besides, I will probably have
              other uses for Twisted later.)

              Donnal Walter
              Arkansas Children's Hospital






              Comment

              Working...