2015-05-12 59 views
0

我試圖獲得在Ruby中從一個系統調用的值的值:獲取系統調用

distro = system('lsb_release -is') 
distver = system('lsb_release -rs | cut -c1-2') 

我想從lsb_release返回進入的變量。但如果我做了puts distroputs distver我只是變成了現實。

有什麼辦法從他們那裏獲得價值嗎?

+0

它已經被問過很多次了。這裏有一個答案:http://stackoverflow.com/questions/690151/getting-output-of-system-calls-in-ruby –

回答

1

你可以去用

d = `date` 
e = IO.popen("date").read 

花一些時間也與IO.popenIO.popen2IO.popen3