I want to use subprocess.check_output() with ps -A | grep \'process_name\'. I tried various solutions but so far nothing worked. Can someone guide
subprocess.check_output()
ps -A | grep \'process_name\'
Using subprocess.run
import subprocess ps = subprocess.run(['ps', '-A'], check=True, capture_output=True) processNames = subprocess.run(['grep', 'process_name'], input=ps.stdout) print(processNames.stdout)