python子进程和捕获bash的`history`命令的stdout

时间:2015-06-18 12:29:31

标签: python bash subprocess

我只是试图通过子进程从python中捕获history命令的输出......并且它不起作用:

import shlex, subprocess, time, os, sys
from subprocess import Popen, PIPE

command_line = "history"
args = shlex.split(command_line)
p = subprocess.Popen(args, stdout=PIPE, stderr=PIPE)

0 个答案:

没有答案