You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Aram Mirzadeh <ar...@gmail.com> on 2008/03/08 23:29:08 UTC

ReadLine takes 3000 ms to read the last line from telnet

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: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: ReadLine takes 3000 ms to read the last line from telnet

Posted by Thorbjørn Ravn Andersen <th...@gmail.com>.
Aram Mirzadeh skrev  den 08-03-2008 23:29:
> 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.
>
>   
Does the CISCO return a "end of line" character after the "Password:" 
string?  If not, then ReadLine cannot tell that the line has ended.

-- 
  Thorbjørn

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org