Hello,

I am opening a telnet stream to a cisco router to login.   Than calling

String foo = readUntil ("Password: ",false);

.. to read in the banner and the "Password" field so that I know when
to send in the auth.

But it looks like readLine times out on the last line, takes 30000 ms
to complete the last read.

readline took 15 ms
 line  = >><<
readline took 0 ms
 line  = >><<
readline took 0 ms
 line  = >>User Access Verification<<
readline took 0 ms
 line  = >><<
readline took 29891 ms
 line  = >>Password: <<

Now I wrote a small test program and pointed readline to a text file
and it seems to finish with no issues, so I am wondering if I'm doing
something wrong with the telnet session?


readline is as follows:

        public String readUntil(String pattern, boolean discard) throws 
IOException
        {
                String data = "";
                BufferedReader br = new BufferedReader(new 
InputStreamReader(in));
                boolean readOn = true;

                while (readOn)
                {
                        String line = "";
                        long t = new Date().getTime();
                        line = br.readLine();
                        t = new Date().getTime() - t;
                        System.out.println("readline took " + t + " ms");
                        if (line != null)
                        {
                                if (line.matches(pattern))
                                        readOn = false;
                                System.out.println(" line  = >>" + line + "<<");
                        }
                        else
                        {
                                readOn = false;
                        }
                }

                if (discard)
                {
                        return null;
                }
                else
                {
                        return (data.toString());
                }
        }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to