I am trying to do something I'm sure I have achieved easily in the past. I want to write write a bash script which opens a new terminal and then runs the following command "picocom -b 115200 /dev/ttyACM0"" and then keeps the terminal window open to act as a serial monitor. I wrote the following script and made it excutable:
#!/bin/bash
# Open a new terminal window and run picocom
gnome-terminal -- picocom -b 115200 /dev/ttyACM0
The script runs without error but a second terminal doesn't open. Even if I run "gnome-terminal -- picocom -b 115200 /dev/ttyACM0" directly in a terminal a second terminal doesn't open.
I have even tried this using xterm instead of gnome-terminal but I cannot get a second terminal to open and run a command, though entering simply "gnome-terminal" will open a clean new terminal.
Edit: The picocom program was simply executing and exiting and closing the terminal window with both gnome-terminal and xterm, as suggested by steeldriver. The solution was to use ";exec.sh" in the command. I find it hard to understand why someone has voted this question down when it is a legitimate and factual question that now has a solution.
gnome-terminal -- sh -c 'picocom -b 115200 /dev/ttyACM0 ; exec sh'
orxterm -e 'picocom -b 115200 /dev/ttyACM0 ; exec sh'
? – steeldriver Mar 19 '24 at 23:12