Created
June 19, 2022 09:30
-
-
Save neibla/440b4bee0dfa4dbaffcc5145b3c56729 to your computer and use it in GitHub Desktop.
Python run process/get output
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 | |
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