import subprocessp = subprocess.Popen(['ls','-a'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)out, err = p.communicate()print out
# work on Unix/Linux only
import commandsprint commands.getstatusoutput('wc -l file')[1]