Created
December 3, 2012 15:33
-
-
Save jhaubrich/4195747 to your computer and use it in GitHub Desktop.
subprocess sucks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def subprocess_sucks(): | |
""" This is what I want to do: | |
stdout = os.system("\ | |
tail --lines 5000 %s/%s_%s/SP1*rpt\ | |
| grep IDM-GIVE-X2 \ | |
| grep -v Metric \ | |
| tail --lines=39" % (path, month, day)) | |
This is what it looks like: | |
""" | |
p1 = Popen(["tail", "--lines 5000", "%s/%s_%s/SP1*rpt" % (path, month, day)], stdout=PIPE) | |
p2 = Popen(["grep", "IDM-GIVE-X2"], stdout=PIPE) | |
p3 = Popen(["grep", "-v Metric"], stdout=PIPE) | |
p4 = Popen(["tail", "--lines=39"], stdout=PIPE) | |
p1.stdout.close() | |
p2.stdout.close() | |
p3.stdout.close() | |
p4.stdout.close() | |
output = p4.comminitcate()[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment