Payal
Payal

Reputation: 1

Calling ruby script from 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.

Upvotes: 0

Views: 1559

Answers (1)

Jared
Jared

Reputation: 39877

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.

Upvotes: 1

Related Questions