3

I am using sshj to communicate from my java application

try {
            final Command cmd = session.exec("tcpdump <some command>");
            System.out.println(IOUtils.readFully(cmd.getInputStream()).toString());
            cmd.join(5, TimeUnit.SECONDS);
            System.out.println("\n** exit status: " + cmd.getExitStatus());
        } finally {
            session.close();
        }

This works like charm, now once i want to kill this process (CTRL + C) using same sshj. I have no clue, Is there any command to do it?

Mwiza
  • 7,780
  • 3
  • 46
  • 42
Shashank Agarwal
  • 512
  • 3
  • 12
  • Looks like this post has some info. Can open your command as a pseudo terminal and then send ctrl+c. https://stackoverflow.com/questions/7330692/killing-a-process-through-sshj – Ehz Feb 14 '17 at 20:34
  • Try `session.allocateDefaultPTY()` as indicated here: https://stackoverflow.com/a/19985859/2346823 – Yoshiya Jun 13 '17 at 14:53

0 Answers0