获取系统调用的值

Getting the value of a system call

我正在尝试从 Ruby 中的系统调用获取值:

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

我认为 lsb_release 中的 return 进入了变量。但是,如果我成为 puts distroputs distver,我就会变得真实。

有什么方法可以从中获取价值吗?

你可以选择

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

也花点时间在 IO.popenIO.popen2IO.popen3 上。