Skip to content

Instantly share code, notes, and snippets.

@neibla
Created June 19, 2022 09:30
Show Gist options
  • Save neibla/440b4bee0dfa4dbaffcc5145b3c56729 to your computer and use it in GitHub Desktop.
Save neibla/440b4bee0dfa4dbaffcc5145b3c56729 to your computer and use it in GitHub Desktop.
Python run process/get output
import subprocess
ls_process = subprocess.run(["ls","/usr/bin"], stdout=subprocess.PIPE)
grep_process = subprocess.run(["grep","python"], input=ls_process.stdout, stdout=subprocess.PIPE)
print(grep_process.stdout.decode("utf-8"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment