Calling another ruby script from a ruby script

Posted by Andrew Grimm on Stack Overflow See other posts from Stack Overflow or by Andrew Grimm
Published on 2010-04-14T05:38:14Z Indexed on 2010/04/14 5:43 UTC
Read the original article Hit count: 437

Filed under:

In ruby, is it possible to specify to call another ruby script using the same ruby interpreter as the original script is being run by?

For example, if a.rb runs b.rb a couple of times, is it possible to replace

system("ruby", "b.rb", "foo", "bar")

with something like

run_ruby("b.rb", "foo", "bar")

so that if you used ruby1.9.1 a.rb on the original, ruby1.9.1 would be used on b.rb, but if you just used ruby a.rb on the original, ruby would be used on b.rb?

I'd prefer not to use shebangs, as I'd like it to be able to run on different computers, some of which don't have /usr/bin/env.

© Stack Overflow or respective owner

Related posts about ruby