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 ———-
- the script is in a directory
- you open that directory in the graphics interface (Nemo, Nautilus, any other file manager)
- you double-click the icon representing the script
- you expect to see a terminal window open, with the script execution in it
———- In your script do ———-
- start a terminal window
- that terminal command includes a call to the script
- and lastly a call to the
readcommand, to keep the window opened until you are done
- you press enter to close the window
———- Ex ———-
#!/bin/bash # xterm -e "/bin/ls /etc; read" &
———- Details ———-
xtermis the command that will be executed in the new window
/bin/ls /etc; readinstead of your script. You would put
your_script.bash arg1 arg2; read
you could do something similar with
readis not essential, it could be a
sleep 5for example. Or if your script already has a delay or something, you might not need anything.
xtermsince it is available on all distributions, which ever window manager you use.