I have a python script, that runs fine if i run in on the console with python3 script.py
. For some reason, the script should be executed via a bash-script "start.sh". A MWE would be
#!/bin/bash
python3 GUIpyPCS.py
When I run the script by double-clicking it, it doesent open a terminal window. Hence, the python script is executed invisibly in the background and not on a new console window.
How can I ensure, that the python script is executed on a console by double-clicking the bash-script? Is there something I can add to the bash script? I am currently testing on Kubuntu 20.04, but the solution should also applicable to other distributions/window managers.
---------- Assumptions ----------
---------- In your script do ----------
read
command, to keep the window opened until you are done---------- Ex ----------
#!/bin/bash
#
xterm -e "/bin/ls /etc; read" &
---------- Details ----------
the -e
option to xterm
is the command that will be executed in the new window
I put /bin/ls /etc; read
instead of your script. You would put your_script.bash arg1 arg2; read
you could do something similar with gnome-terminal
instead of xterm
the read
is not essential, it could be a sleep 5
for example. Or if your script already has a delay or something, you might not need anything.
I used xterm
since it is available on all distributions, which ever window manager you use.