Last active
December 27, 2015 09:49
-
-
Save samuell/7306958 to your computer and use it in GitHub Desktop.
A convenience method for executing external commands and getting the output, in python
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
| import subprocess as sub | |
| def exec_cmd(commandstr): | |
| proc = sub.Popen(commandstr, stdout=sub.PIPE, shell=True) | |
| return proc.communicate()[0].strip() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Learned, in this thread [1], that I can do:
... or (if using http://amoffat.github.io/sh/):
Nice!
[1] https://plus.google.com/u/0/106548631604770110294/posts/Z87xvsNcGWY