Python 2.7.9 on Linux Here is a bash command that I want to run from a python program: sudo grep "^user\:" /etc/shadow
If I enter the command directly into a terminal it works perfectly. If I run it from a python program it returns an empty string. Below is the code I am using. Suggestions appreciated. cmdlist = ["sudo", "grep", '"^$USER\:"', "/etc/shadow"] p = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE) shadow, err = p.communicate() print shadow -- <Wildman> GNU/Linux user #557453 -- https://mail.python.org/mailman/listinfo/python-list