ps = subprocess.Popen(('ps', '-A'), stdout=subprocess.PIPE) output = subprocess.check_output(('grep', 'process_name'), stdin=ps.stdout) ps.wait()