-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
https://docs.python.org/2/library/subprocess.html
http://en.wikipedia.org/wiki/Here_document
import subprocess
subprocess_call = subprocess.Popen(args='ls -ltr', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
# Using communicate() will suspend the script until the subprocess is complete
output = subprocess_call.communicate()
stdout = output[0]
stderr = output[1]
heredoc = "<<SCRIPT\n"
heredoc += "cd /home/wassjas\n"
heredoc += "ls -ltr\n"
heredoc += "pwd\n"
heredoc += "SCRIPT"
heredoc_call = subprocess.Popen(args=heredoc, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
# Communicate blocks until subprocess call finishes
heredoc_out = heredoc_call.communicate()
heredoc_stdout = heredoc_out[0]
heredoc_stderr = heredoc_out[1]@vraghunandan @bdambola @kwokman @dsapienza @DRozentsvay @gganeshan @cbautista1002 @xingj53 @wcorrea @rklotz @isehgu @akbamaa
Metadata
Metadata
Assignees
Labels
No labels