View original Gist on GitHub
from subprocess import Popen, PIPE cmd = 'grep "^name" /etc/resolv.conf | grep -v "0.0.0.0" | cut -d " " -f 2' result = Popen(cmd, shell=True, stdout=PIPE) print result.stdout.read()