Run the command "stty raw" in the same terminal?

I am trying to put the console in raw mode in Java. I understand that this will only work on UNIX.

I use the command stty raw

If I type a command directly into the terminal, it does what it should do. In Java, I am trying to set this mode:

Runtime.getRuntime().exec("stty raw");

But the terminal does not go into raw mode.

I have a feeling because Java just executes a command in a virtual terminal in the background or something, and not in the active terminal. Is there any way to do this?

+3
source share
2 answers

Since the JVM redirects stdio / stdout / stderr, you can try something like this:

String[] cmd = {"/bin/sh", "-c", "stty raw </dev/tty"};
Runtime.getRuntime().exec(cmd);

, stty () stdin not stdout.

+5

stty ioctl . exec, .

- JNI Java- GUI . Heck, Java 100%.

-1

Source: https://habr.com/ru/post/1782118/


All Articles