There is a menu item that gets displayed on the console after the connection of the session. And that menu items have command with F1, F2, F3
String host="myhost.abc.123";
String user="devuser";
String password="dev1234";
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
JSch jsch = new JSch();
Session session = null;
ChannelShell channel = null;
session = jsch.getSession(user, host, 22);
session.setPassword(password);
session.setConfig(config);
session.connect();
System.out.println("Connected");
channel = (ChannelShell) session.openChannel("shell");
OutputStream out_s = channel.getOutputStream();
channel.connect();
I want to send the F2 - function key as a hardcoded escape sequence or from the keyboard, to server. Tried below options but I am not getting the next response/output
/* --- code for printing the menu item on the console/screen ---
MENU ITEMS GET PRINTED ON THE CONSOLE
F1 - ADD F2 - UPDATE F3 - DELETE
*/
//Try 1. F2 - ESC[OQ
out_s.write("\033[OQ".getBytes()); // may require \n or \r to enter the cmd
out_s.flush();
//Try 2. F2 - ESC[12~
out_s.write("\033[12~".getBytes()); // may require \n or \r to enter the cmd
out_s.flush();
//Try 3. F2 - \E[12~
out_s.write("\\E[12~".getBytes());
out_s.flush();
//Try 4. F2 - 0x71
out_s.write((byte)0x71); // may require \n or \r to enter the cmd
out_s.flush();
//Try 5. F2 - \ESC[OQ
out_s.write("\\ESC[OQ".getBytes());
out_s.flush();