telnet.read_until() from telnetlib

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jacek Pop³awski

    #1

    telnet.read_until() from telnetlib

    I have strange problem with telnetlib.

    r=self.telnet.r ead_until(expec ted,timeout)

    It works in most cases (hundrets of iterations), but sometimes "r" doesn't
    contain "expected", first I thought that server is responding incorrectly, then
    I realized that read_until doesn't wait timeout seconds!

    example output (value of r):

    "#"

    while I was expecting "config#"

    value of timeout is 20

    PS. Python 2.4.1, Cygwin.

    --
    Free Software - find interesting programs and change them
    NetHack - meet interesting creatures, kill them and eat their bodies
    Usenet - meet interesting people from all over the world and flame them
    Decopter - unrealistic helicopter simulator, get it from http://decopter.sf.net
  • sp1d3rx@gmail.com

    #2
    Re: telnet.read_unt il() from telnetlib

    Czesc Jacek:
    Please post the minimum code necessary to duplicate the problem.

    Dzieki,
    Derek Wilson

    Comment

    • sp1d3rx@gmail.com

      #3
      Re: telnet.read_unt il() from telnetlib

      after doing some research, I would suggest trying self.telnet.exp ect().
      This will give you more data about the cause of the failures.

      Comment

      • Jacek Pop³awski

        #4
        Re: telnet.read_unt il() from telnetlib

        my newsreader told me that sp1d3rx@gmail.c om wrote:[color=blue]
        > Please post the minimum code necessary to duplicate the problem.[/color]

        It's impossible, because I am writting performance tests for big commercial
        project, I am trying to understand why they sometime fail. By definition of
        "read_until ()" it should return expected data (if it doesn't wait timeout
        seconds).
        Anyway, I am trying to use "telnet.exp ect" now, thanks.

        --
        Free Software - find interesting programs and change them
        NetHack - meet interesting creatures, kill them and eat their bodies
        Usenet - meet interesting people from all over the world and flame them
        Decopter - unrealistic helicopter simulator, get it from http://decopter.sf.net

        Comment

        • Jacek Pop³awski

          #5
          Re: telnet.read_unt il() from telnetlib

          I have same problem with expect :-(

          I am calling:

          l=[expected]
          result=self.tel net.expect(l,ti meout)

          it works in most cases, but sometimes (with exacly same "expected" value) it
          returns -1,Nil,"some text"
          the point is, that:
          - connection is still active, so it should read more!
          - it doesn't wait timeout seconds (I used time.time() to check that, time is
          zero, timeout is about 20s)!

          In what case "expect" or "read_until " will stop reading without waiting for
          timeout?

          --
          Free Software - find interesting programs and change them
          NetHack - meet interesting creatures, kill them and eat their bodies
          Usenet - meet interesting people from all over the world and flame them
          Decopter - unrealistic helicopter simulator, get it from http://decopter.sf.net

          Comment

          • sp1d3rx@gmail.com

            #6
            Re: telnet.read_unt il() from telnetlib

            but the 'expect' gives you more details about the failure... read the
            documentation on telnet objects here:
            "http://docs.python.org/lib/telnet-objects.html".
            It says this specifically:
            "If end of file is found and no text was read, raise EOFError.
            Otherwise, when nothing matches, return (-1, None, text) where text is
            the text received so far (may be the empty string if a timeout
            happened). "

            Comment

            • Jacek Pop³awski

              #7
              Re: telnet.read_unt il() from telnetlib

              my newsreader told me that sp1d3rx@gmail.c om wrote:[color=blue]
              > "If end of file is found and no text was read, raise EOFError.
              > Otherwise, when nothing matches, return (-1, None, text) where text is
              > the text received so far (may be the empty string if a timeout
              > happened). "[/color]

              What if:
              - exception has not been raised
              and:
              - time passed is smaller than timeout?
              How to interpret such behaviour?


              --
              Free Software - find interesting programs and change them
              NetHack - meet interesting creatures, kill them and eat their bodies
              Usenet - meet interesting people from all over the world and flame them
              Decopter - unrealistic helicopter simulator, get it from http://decopter.sf.net

              Comment

              • sp1d3rx@gmail.com

                #8
                Re: telnet.read_unt il() from telnetlib

                then you are using a regex expression that is a wildcard match, and
                that is non-deterministic.

                Comment

                Working...