0
我试图获得在Ruby中从一个系统调用的值的值:获取系统调用
distro = system('lsb_release -is')
distver = system('lsb_release -rs | cut -c1-2')
我想从lsb_release
返回进入的变量。但如果我做了puts distro
或puts distver
我只是变成了现实。
有什么办法从他们那里获得价值吗?
我试图获得在Ruby中从一个系统调用的值的值:获取系统调用
distro = system('lsb_release -is')
distver = system('lsb_release -rs | cut -c1-2')
我想从lsb_release
返回进入的变量。但如果我做了puts distro
或puts distver
我只是变成了现实。
有什么办法从他们那里获得价值吗?
你可以去用
d = `date`
e = IO.popen("date").read
花一些时间也与IO.popen
,IO.popen2
,IO.popen3
。
它已经被问过很多次了。这里有一个答案:http://stackoverflow.com/questions/690151/getting-output-of-system-calls-in-ruby –