I'm trying to get output of
dmesg | grep -i 'bios' I've tried this:
dmsg = subprocess.check_output("dmesg | grep -i 'bios'").decode('utf-8') , but I'm getting an error.
How can I obtain a full sdtoutput message?
You can pipe using Popen passing the stdout of one one process to the stdin of another but you also parse the output of dmesg with python instead of running two processes:
import subprocess dmsg = subprocess.check_output("dmesg",universal_newlines=True).splitlines() print([line for line in dmsg if "bios" in line.lower()]) If you were trying to pipe using check_output you would need to use shell=True:
import subprocess dmsg = subprocess.check_output("dmesg | grep -i 'bios'",shell=True).decode('utf-8')
shell=True