xxxxxxxxxx
import os
os.system("Command") # this is your cmd/terminal
xxxxxxxxxx
import os
os.system("ma Commande")
#Exemple:
os.system("cd Documents")
xxxxxxxxxx
import subprocess
import sys
# Some code here
pid = subprocess.Popen([sys.executable, "longtask.py"]) # Call subprocess
# Some more code here
xxxxxxxxxx
import subprocess
# for simple commands
subprocess.run(["ls", "-l"])
# for complex commands, with many args, use string + `shell=True`:
cmd_str = "ls -l /tmp | awk '{print $3,$9}' | grep root"
subprocess.run(cmd_str, shell=True)
xxxxxxxxxx
from os import system
system("echo off")
system("echo print(\"hi\") > file.py")
system("py file.py")
xxxxxxxxxx
import subprocess
list_dir = subprocess.Popen(["ls", "-l"])
list_dir.wait()