我正在编写一个应用程序,通过SSH连接到服务器,打开一个应用程序(它在shell上运行)并使用它。我正在使用JSch,并设法连接,打开应用程序并向其发送命令。现在我面临两个问题:JSch Esc命令和编码
- 在Windows上我有与应用程序的编码问题(在Linux上,如果我使用IDE控制台输出来运行它,我有同样的问题,那只能说明对上的bash )。这里有一个screehshot:
这里是它应该表现出什么样的截图:
我运行的应用程序,使得使用ESC键的,我不能在应用程序中我已经写使用它。它只是在输出 写道:
^[
这里是我用来做这个应用程序的代码:JSch shell = new JSch(); Session session = shell.getSession("myUser", "myHost"); session.setPassword("myPassword"); session.setConfig("StrictHostKeyChecking", "no"); session.connect(); Channel channel = session.openChannel("shell"); channel.setOutputStream(System.out); PipedInputStream in = new PipedInputStream(); PipedOutputStream out = new PipedOutputStream(in); channel.setInputStream(in); channel.connect(); out.write("my_application\n".getBytes()); Thread.sleep(1000); //waiting for the app to load out.write("\n".getBytes()); out.write("appUser\n".getBytes()); out.write("appPassword\n".getBytes()); channel.setInputStream(System.in);
PS:服务器使用sh和bash的不是。
我认为可能存在一个问题,在窗口呈现颜色的可行性 – Augusto