Open a terminal window and run script using st.button

Hi everyone,

Using streamlit first time and already my head is full of potential apps I want to make with it beyond the data science stuff. So, here goes my question.

One of the thing I am doing is trying to run another python script from the terminal on the Mac after clicking a button. Basically, the user will be using the dropdowns to select a few options which will be used as arguments to my other python script. To open the terminal, I use the following.

run_button = st.button(‘Run’)
command = f"osascript -e ‘tell application {final_app} to do script {final_command}’"

if run_button:

However, no new terminal opens. No error comes up as well. Any hints on how to accomplish this?


Hi @excalibre, welcome to the Streamlit community!

While running a subprocess isn’t uncommon, actually bringing up a terminal window is a bit less so. I’m not sure that a browser-based app (i.e. a web page) has the ability to do that (I’m not certain).

For hints on how to use a subprocess in a Streamlit app, please see the docs where we give a minimal example:


If I understood, you don’t want to show a terminal window. You want to execute a command when the button is clicked. In this case, you can use a lib called Paramiko, and execute the command via ssh