1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| from subprocess import Popen, PIPE
from os import waitpid, getcwd
from time import sleep
from os.path import join
print ("Lancement de la commande")
output = Popen([join(getcwd(), "test.sh")], stdout=PIPE).communicate()[0]
print ("Attente") # Pour montrer que ce n'est pas la sortie standard
sleep(2.0)
print ("Sortie")
sleep(1.0)
print output
sleep(2.0)
print ("Lancement de la commande avec shell")
output = Popen([join(getcwd(), "test.sh")], shell=True, stdout=PIPE).communicate()[0]
print ("Attente")
sleep(2.0)
print ("Sortie")
sleep(1.0)
print output |