Skip to content

Instantly share code, notes, and snippets.

@vik-y
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save vik-y/e4d936e710b0042a1673 to your computer and use it in GitHub Desktop.

Select an option

Save vik-y/e4d936e710b0042a1673 to your computer and use it in GitHub Desktop.
Run shell command and capture output using python
def run_terminal(command):
p = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
return out
@vik-y

vik-y commented May 14, 2015

Copy link
Copy Markdown
Author

use os.system("command") instead if you just want to execute a command and don't care about the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment