我有这个代码
`ifconfig`
%x(ifconfig)
system("ifconfig")
当我运行它时,只有“系统(“ifconfig”)”有效。我知道是因为我先分别运行它们。
反引号和 %x 变体在变量中返回结果的输出。system()将调用命令并返回!!return_code。
1.9.3p327 :001 > `ifconfig`
 => "eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>..."
1.9.3p327 :002 > %x(ifconfig)
 => "eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>..."
1.9.3p327 :003 > system("ifconfig")
eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
...
 => true