1import subprocess
2subprocess.run(["bash", "testShell.sh"])
3#we don't have to give full path to the shell script. It always execute from the current directory
4
5#As a rule of thumb, you need to separate the arguments based on space,
6#for example ls -alh would be ["ls", "-alh"], while ls -a -l -h,
7#would be ["ls", "-a", -"l", "-h"]. As another example,
8#echo hello world would be ["echo", "hello", "world"],
9#whereas echo "hello world" or echo hello\ world would
10#be ["echo", "hello world"].
11
12#Another example.
13list_files = subprocess.run(["ls", "-l"])
14print("The exit code was: %d" % list_files.returncode)
1import subprocess
2subprocess.call(["./shell.sh"])
3
4# Make sure that "shell.sh" has "+x" permissions