使用ganymed SSH2发送SIGINT CTRL-C? [英] sending SIGINT CTRL-C using ganymed SSH2?

查看:413
本文介绍了使用ganymed SSH2发送SIGINT CTRL-C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要杀死一个我开始使用ganymed SSH2的进程。具体来说,我想使用 Ctrl + C 优雅地杀死它。我已经看到了尝试发送ASCII \ x03 的想法,但是在使用execCommand()时它不会使用转义字符。如何通过ganymed发送 Ctrl + C SIGINT?

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?

如果有另一个Java SSH应用我应该是使用让我知道,我已经调查了Jsch,sshj,但只是发现ganymed ssh2是最简单的。

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.

我想杀死的程序是tethereal(wireshark)

The program i am trying to kill is tethereal (wireshark)

推荐答案

我用JSch成功发送 Ctrl + C

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();

这篇关于使用ganymed SSH2发送SIGINT CTRL-C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆