The subprocess module will help you out.
Blatantly trivial example:
>>> import subprocess
>>> subprocess.call(['sh', './test.sh']) # Thanks @Jim Dennis for suggesting the []
0
>>>
Where test.sh
is a simple shell script and 0
is its return value for this run.
More Related Contents:
- how to get the time after two minutes [closed]
- Why do people write #!/usr/bin/env python on the first line of a Python script?
- Using sudo with Python script
- Python: execute cat subprocess in parallel
- Is there a simple way to get rid of junk values that come when you SSH using Python’s Paramiko library and fetch output from CLI of a remote machine?
- How to escape os.system() calls?
- Run Python script without Windows console appearing
- Running windows shell commands with python
- Execute multiple commands in Paramiko so that commands are affected by their predecessors
- Execute terminal command from python in new terminal window?
- subprocess.call() arguments ignored when using shell=True w/ list [duplicate]
- how to run python script without typing ‘python …’
- File not found error when launching a subprocess containing piped commands
- How to print UTF-8 encoded text to the console in Python < 3?
- Shell Script: Execute a python program from within a shell script
- python getoutput() equivalent in subprocess [duplicate]
- Checking for interactive shell in a Python script
- Clear screen in shell
- How to recognize whether a script is running on a tty?
- Conda command working in command prompt but not in bash script
- How to store the result of an executed shell command in a variable in python? [duplicate]
- Calling a python script from command line without typing “python” first
- Execute multiple dependent commands individually with Paramiko and find out when each command finishes
- Python: subprocess call with shell=False not working
- How to run a python script from IDLE interactive shell?
- Can’t execute shell script from python subprocess: permission denied
- Hiding console output produced by os.system
- Cannot find the file specified when using subprocess.call(‘dir’, shell=True) in Python
- How to execute a script remotely in Python using SSH?
- Python | change text color in shell [duplicate]