xxxxxxxxxx
import subprocess
subprocess.call(["sudo", "apt", "update"])
xxxxxxxxxx
import subprocess
print "start"
subprocess.call("sleep.sh")
print "end"
xxxxxxxxxx
import subprocess
# Example command that you want to run
command = "ls -l"
# Run the command using subprocess.call() function
subprocess.call(command, shell=True)
xxxxxxxxxx
import subprocess
output = subprocess.check_output('pidstat -p ALL'.split(' '), stderr=subprocess.STDOUT, universal_newlines=True)
print(output)
xxxxxxxxxx
import subprocess
# Replace 'script.sh' with the actual name/path of your bash script
script_path = '/path/to/script.sh'
# Run the bash script
result = subprocess.run(['bash', script_path], capture_output=True, text=True)
# Print the output of the script
print(result.stdout)