Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ruby编写脚本_Ruby - Fatal编程技术网

使用ruby编写脚本

使用ruby编写脚本,ruby,Ruby,我想使用ruby脚本来安装rails工作环境所需的所有东西 我不知道我怎么能跑 `sudo aptitude install <appname>` `sudo智能安装` 实际上,可以看到生成的输出,就像我在命令行中运行该行一样 当我被提示输入一些东西时,我就可以这样做了 这可能吗 谢谢使用系统 system 'sudo aptitude install <appname>' 系统“sudo智能安装” 如果命令执行成功,则返回true;如果出现错误,则返回false

我想使用ruby脚本来安装rails工作环境所需的所有东西

我不知道我怎么能跑

`sudo aptitude install <appname>`
`sudo智能安装`
实际上,可以看到生成的输出,就像我在命令行中运行该行一样

当我被提示输入一些东西时,我就可以这样做了

这可能吗


谢谢

使用
系统

system 'sudo aptitude install <appname>'
系统“sudo智能安装”

如果命令执行成功,则返回true;如果出现错误,则返回false。所有输出都将定向到
$stdout
/
$stderr

使用
系统

system 'sudo aptitude install <appname>'
系统“sudo智能安装”

如果命令执行成功,则返回true;如果出现错误,则返回false。如果appname包含任何有趣的字符,则所有输出将被定向到
$stdout
/
$stderr

,作为对Adrian的微小更正:

system 'sudo', 'aptitude', 'install', appname

system *%W[sudo aptitude install #{appname}]

作为对Adrian的微小更正,如果appname包含任何有趣的字符:

system 'sudo', 'aptitude', 'install', appname

system *%W[sudo aptitude install #{appname}]