我想调用一个返回字符串的命令,我想在 ruby 脚本中调用此命令,并访问结果。
最佳答案
我假设你所说的命令是指操作系统命令。
# this will execute ls and assign the dir listing to the variable
dir_list = `ls`
os_user = `whoami`
关于windows - 如何在 Ruby 中调用 dos 命令并获取结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2375282/