Send Escape Keystroke To Telnet With Java

I had a very hard time trying to figure out how to send "CTRL+A" to a Telent session through Java. (for an AS/400 telnet session).


First obstacle was finding what the key mapping was. I found this on midrange.com. "CTRL+A maps to "Escape, A". [link]

Using TelnetWrapper library here: [link]
I found the Escape Key value here: [link]

What confused me at first was the use of the word "Escape" in the Telnet specification. There are special escaped keys that would normally use the TelnetProtocolHandler's sendTelnetControl(byte code) function. This is not the case. Here's how I did it:

TelnetWrapper t = new TelnetWrapper();
t.connect(hst, prt);
t.waitfor("User . . . . . . . . . . . . . .");
t.send(user + "\t" + pwd);
byte[] b = new byte[] {'\033', 'a'};
t.write(b);
System.out.println(t.waitfor(""));

-Tres

Comments

Popular posts from this blog

Dell Zino HD Remote Standard

iPod Touch iPhone 3G Ubuntu 9.10 in 5 minutes

Pidgin - Microsoft Office Communicator