美文网首页
python call linux cmd

python call linux cmd

作者: 金色的清晨 | 来源:发表于2016-10-21 10:48 被阅读0次

history

old version use

result = commands.getstatusoutput('ls -l')
print result

now use subprocess32

install

sudo apt-get install python-dev
pip install subprocess32

use

#!/usr/bin/env python

import subprocess32 as subprocess;

proc = subprocess.Popen(['grep', '86b45e8625ce', 'arns_file'], stdout=subprocess.PIPE);
result = proc.stdout.read();
print result;

相关文章

网友评论

      本文标题:python call linux cmd

      本文链接:https://www.haomeiwen.com/subject/qnnquttx.html