0

I tried to run String command ="gdb -p <124845> --batch -ex 'call shutdown(69u)'" or close() instead of shutdown(). Using Runtime.getRuntime().exec(command);

COMMAND GETS EXECUTED BUT HAS NO EFFECT ,

But when run in putty then it works fine.

PLEASE help ,i'm new to this.

My goal is to clear all connections to a java socket in linux machine.

6
  • You should specify pid number without angle brackets like this -p 124845. The command with angle brackets should not work fine when it run in putty also. Commented Apr 27, 2020 at 17:44
  • Im using without angle bracket only, i just showed that way, query is running as well from java but its not closing the connection Commented Apr 27, 2020 at 17:53
  • The .exec is breaking up the command into tokens but doesn't understand what single quotes mean, so it's running the command with the argument list ["gdb", "-p", "124845", "--batch", "-ex", "'call", "shutdown(69u)'"]. Can you see if the following answers your question? Java execute command doesn't work in code Commented Apr 28, 2020 at 18:18
  • Thanks ill try this also, but even earlier it was returning the same response in process.inpustream as it returns in command prompt but it was not actually closing the connection, ill check of this works ty Commented Apr 28, 2020 at 18:29
  • The gdb --batch option will return exit code 0 in many cases, even if accompanied by -ex options that fail. gdb --batch -ex UnknownCommand returns 0. Commented Apr 28, 2020 at 19:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.