Originally Posted by
EoD
...I had the impression that Windows and Linux received different invisible characters at some (not all) lines.
I ran the program as well as manual telnet sessions from a Linux command line and piped the output to "tee" so that I could capture everything in a file.
java TelnetIO | tee TelnetIO.out
And
telnet horizons.jpl.nasa.gov 6775 | tee telnet.out
Some telnet clients may have a "log" mode that captures output, but "tee" works for me.
The point being that I could look at the output files without depending on pasting stuff from the console window. (There is a lot of stuff that gets overwritten as well as a few non-printing chars that I wanted to examine.) Also I could easily paste all of the complete server prompts into my code to eliminate those annoying typos that might tempt me to take shortcuts (like using case-insensitive abbreviated terms).
There are a number of places where stuff coming from the server don't remain on the screen because of some ANSI escape sequences. Most of the lines have "\cr\nl" at the end of the lines, but some of them have "\cr\cr\nl"
Because of the way that the code in getData splits the payload and creates the "Final Result" the lines are separated by '\cr' with no '\lf' So in order to make sure I see them on the screen as well as in the capture file, my main() looks something like
public static void main(String[] args) {
TelnetIO socket1 = new TelnetIO();
String retStr = socket1.getData(399);
// retStr has three lines separated by '\r'.
// Change them to '\n' so that they display
// OK on Linux
// Could replace them by "\r\n" if your operating
// system likes DOS stuff.
String finalStr = retStr.replace("\r", "\n");
System.out.println("The final result is:\n"+finalStr);
}
At the beginning of readData, it looks like this
while ((len = reader.read(buffer)) != -1) {
//System.out.printf("len = %d\n", len);
String readchar = new String(buffer, 0, len);
System.out.printf("From server: %s (", readchar);
// Uncomment this if you can't look at the file with
// a hex editor and you want to see the ANSI escape
// sequences and the handful of Unicode chars at the start
//for (int i = 0; i < len; i++) {
//System.out.printf("%02x ", buffer[i]);
//}
System.out.printf(")\n");
Originally Posted by
EoD
Almost same code as last time (should I stop posting it?)
No need to post more code unless you get stuck. I am interested in your progress, but I am not sure how much more I can help. I'm thinking that you are going great guns!
Cheers!
Z