I'm working on a linux pinephone script that would launch a touchpad emulator. In order to do so, I need to compare the output string of:
./TouchpadEmulator /dev/input/event2 /dev/input/event1
once I hit enter the terminal shows
max x:719 max y:1439
and the terminal remains open, without showing any command prompt, which means that the code keeps running in background.
My problem is that I'm trying to output this "max x:719 max y:1430" to some variable, some file, or as an argument for a next command.
I've tried something like
./TouchpadEmulator /dev/input/event2 /dev/input/event1 > textfile.txt
but the textfile.txt remains empty.
I've also tried
echo $(./TouchpadEmulator /dev/input/event2 /dev/input/event1)
but the terminal screen remains blank.
My guess is that since the command keeps running in background, the echo never executes, since it waits until the "./TouchpadEmulator ... " is completely executed.
2> textfile.txt
. Readman bash
. – waltinator Jul 24 '21 at 23:18stdbuf -oL ./TouchpadEmulator /dev/input/event2 /dev/input/event1 > textfile.txt
to force line-buffered output – steeldriver Jul 24 '21 at 23:23xrandr
. Minor unrelated comment: The command is running in the foreground, not in the background. – Kusalananda Jul 25 '21 at 06:59