I'm working in a remote server that uses Scientific Linux (version=7.6 (Nitrogen)). I did a simple web application in Python3, and I found myself constantly opening a Mate Terminal (though, any terminal works), and writing
bash
python3 my_app.py
So, I can check if my app works locally in my browser.
I want a way to make this easier, and just click a shell script that opens a terminal windows and runs the commands mentioned. After that, the terminal window should remain open and I should be able to check my web application in the browser.
I wrote a shell script with this line:
gnome-terminal --tab --title="tab 1" --command="bash -c 'python3 my_app.py; $SHELL'"
As recommended here, in the case of Ubuntu: https://askubuntu.com/questions/46627/how-can-i-make-a-script-that-opens-terminal-windows-and-executes-commands-in-the (Note: I tried all other answers and they didn't work, Gabriel Staples answer was the only one that almost worked). I also allowed the file to be executed as program.
There are 2 problems with this solution. First, the terminal does not remain open. Second, when I click the file I received the following message (before terminal is closed): ModuleNotFoundError: No module named 'flask'
. This is because the script is using the wrong version of python3 in this server. There is one installed by the admin, and the anaconda version installed by me in my home directory. I've been getting around this problem by writing bash
before using python3 my_app.py
. It seems that after I use bash
the file .bashrc in my home directory is used, and the variable $PATH
gives priority to my version of python3 (I checked that $PATH
is different before and after I write bash
in the terminal).
I was wondering if there is a way to make a script (on Scientific Linux) that opens a terminal window and executes commands in them, and after that remains open.
I also was wondering if there is a way that the web application automatically pops up in my browser after this.
screen
ortmux
rather than a GUI terminal window.