sending SIGINT CTRL-C using ganymed SSH2?
I need to kill a process that I have started using ganymed SSH2. Specifically I would like to gracefully kill it using Ctrl+C. I have seen ideas of trying to send ASCII \x03
but 开发者_运维百科when using the execCommand() it wont take escaped chars. How can I send Ctrl+C SIGINT through ganymed?
If there is another Java SSH app I should be using let me know, I have looked into Jsch, sshj but just found ganymed ssh2 to the be easiest.
The program i am trying to kill is tethereal (wireshark)
I've used this with JSch to successfully send Ctrl+C:
JSch jsch = new JSch();
Session session = jsch.getSession(user, host);
session.setPassword(password);
session.connect(timeout);
Channel channel = session.openChannel("shell");
channel.connect();
OutputStream out = channel.getOutputStream();
...
out.write(3); // send CTRL-C
out.flush();
精彩评论