I am using the following two lines of Python code to open a new Terminal window from a Python script, and this works fine:
import os
os.system('open -a Terminal .')
Now I would like to pass the new Terminal window a command to be executed, for example
ls
How can I do that?
Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. Python is a general-purpose language, meaning it can be used to create a variety of different programs and isn't specialized for any specific problems.
Dec 14, 2020. The Python += operator lets you add two values together and assign the resultant value to a variable. This operator is often referred to as the addition assignment operator.
Python is widely considered among the easiest programming languages for beginners to learn. If you're interested in learning a programming language, Python is a good place to start. It's also one of the most widely used.
Python has a simple syntax similar to the English language. Python has syntax that allows developers to write programs with fewer lines than some other programming languages. Python runs on an interpreter system, meaning that code can be executed as soon as it is written.
Try this
import appscript
appscript.app('Terminal').do_script('ls') # or any other command you choose
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With