Skip to content Skip to sidebar Skip to footer

Open A Terminal In Python Script And Execute Terminal Commands In That Newly Opened Terminal

I need to create a Python script to open a terminal window in Mac/Linux and need to execute the following commands in terminal from Python script. Open terminal Execute the comman

Solution 1:

I don't fully understand the wording of your question, but if you want to pop up a Terminal and run:

ls -l 

in that Terminal, you can do:

import os
os.system("""osascript -e 'tell application "Terminal" to do script "ls -l"'""")

Post a Comment for "Open A Terminal In Python Script And Execute Terminal Commands In That Newly Opened Terminal"