commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anthony Webster" <...@tentelemed.com>
Subject Trouble with TelnetClient use
Date Thu, 28 Feb 2008 10:54:35 GMT
Hello all,

 

I’m having a bit of trouble with the TelnetClient class. Up until recently
my code worked fine using the readUntil strategy:

 

private String readUntil(String pattern) throws Exception

{

char lastChar = pattern.charAt(pattern.length() - 1);

            StringBuffer sb = new StringBuffer();

            char ch = (char) in.read();

            while (true) {

sb.append(ch);

                        if (ch == lastChar) {

                                   if (sb.toString().endsWith(pattern)) {

                                               return sb.toString();

                                   }

                        }

                        ch = (char) in.read();

            }

}

 

I simply read from the TelnetClient’s InputStream until I encounter a
specified character or chain of characters. 

 

This worked fine but now I’m confronted with a situation (telneting to a
LinkStar satellite modem) where the format of command returns can vary from
day to day and there is not prompt character which I can key off (all I get
is a blinking underscore). This makes parsing command results near
impossible.

 

I was wondering if anyone here had encountered similar problems and how they
had been solved.

 

Many Thanks in advance

 

Anthony WEBSTER

Telemedicine Technologies S.A.

88, rue du Dôme

92100, Boulogne-Billancourt

 

T : +33 1 55 20 08 04

F : +33 1 49 10 06 52

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message