2
有一个我想调用的命令会返回一个字符串,我想在ruby脚本中调用这个命令,并且可以访问结果。如何在Ruby中调用dos命令并获取结果?
有一个我想调用的命令会返回一个字符串,我想在ruby脚本中调用这个命令,并且可以访问结果。如何在Ruby中调用dos命令并获取结果?
我假设你的意思是一个操作系统命令。
# this will execute ls and assign the dir listing to the variable
dir_list = `ls`
os_user = `whoami`
你有方法Kernel#system
太http://ruby-doc.org/core/classes/Kernel.html#M005971
system "dir"
KandadaBoggu,是你!你击败了我! (+1) – 2010-03-03 22:16:42
@smotchkkiss低挂果实:-)。该死的游戏是令人上瘾的。 – 2010-03-03 22:21:46