Python

一般执行系统命令:

import os
os.system('date')

获取系统命令的输出:

import os
stdout = os.popen('date')
content = stdout.read().strip() # strip() can remove '\n' in the end

获取系统返回值:

import commands
(status, output) = commands.getstatusoutput('date')

Ruby

执行系统命令:

`date`
exec 'date'
system 'date'
Comments
Write a Comment