I'm trying to run some tests in Ruby that requires running external Ruby files/programs.
In Windows console I use irb to run Ruby program that calls another Ruby program located in this same directory like this:
irb(main):018:0> puts system "ruby1.8 tmp.rb"
false
=> nil
However it always return false.
How can I solve this problem.
I have several versions of Ruby installed on Windows and I need to run a specific version of Ruby chosen on the command line.
I have already tried to rename executable ruby.exe to ruby1.8.exe and it works properly from the command line but not with the 'system' command.
1 Answer 1
From the docs:
system returns true if the command gives zero exit status, false for non zero exit status.
Use backticks instead of system
to capture the output:
output = `ruby tmp.rb`
p output
tmp.rb
fileruby1.8 tmp.rb
directly from the Windows console?