从groovy调用ruby脚本 [英] Calling ruby script from groovy
问题描述
我有一个groovy脚本,我需要调用一个ruby脚本。
我想将参数传递给Ruby脚本,并希望捕获Ruby的输出脚本在Groovy Script中使用它。有人可以建议我怎么做到这一点?我试过 Process.execute()
。它适用于其他dos命令,但不适用于 cmd / c ruby test.rb
。
$ p $
Process.execute(ruby.exe test.rb)
假设ruby.exe在你的路径上。取决于您的要求的另一种选择可能是使用 JRuby ,这将允许您在JVm上运行Ruby代码并很好地集成与Groovy。
I have a groovy script and I need to call a ruby script.
I would like to pass arguments to Ruby script and would like to capture the output from Ruby script to use it in Groovy Script. Can somebody suggest how I can do this? I tried Process.execute()
. It works for other dos commands but not for cmd /c ruby test.rb
.
Since a ruby file isn't a batch file you don't need to use cmd to execute it. You could do
Process.execute("ruby.exe test.rb")
Assuming ruby.exe is on your path. Another option depending on your requirements may be to use JRuby which will allow you to run ruby code on the JVm and integrate nicely with Groovy.
这篇关于从groovy调用ruby脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!