I have a script which runs in the background (without terminal windows or TTY) and occasionally does something.
I now want it to do another thing when it does something and it is to open a Gnome Terminal window and execute 2 commands. Actually, I only need to execute 1 command but I want to make the terminal window stay open so I can see the output of the command. The command prints both on stdout and stderr and its output changes over time, so just writing it to a file and sending some kind of notification wouldn't do the job very well.
I can get Gnome Terminal to open a window and execute 1 command:
gnome-terminal -e "sleep 10"
I chose sleep
as the long-running command for simplicity. However, when adding another command, no terminal window opens:
gnome-terminal -e "echo test; sleep 10"
What's the solution to this?
Best Answer
gnome-terminal
treats everything in quotes as one command, so in order to run many of them consecutively you need to start interpreter (usually a shell), and do stuff inside it, for instance:BTW, you may want the window to stay open even after commands finish their job, in such case just start new shell, or replace a current with the new one: