I want to log the current Ruby version to a log file along with the
script version, but I don't know how to get the Ruby version from
within a running script.
I tried:
puts system("ruby -v")
but that only returns "true" from within a script. (I see the correct
output when I run it in IRB, but the script doesn't capture that.)
I also tried :
puts Config::CONFIG["ruby_version"]
I want to log the current Ruby version to a log file along with the
script version, but I don't know how to get the Ruby version from
within a running script.
the constant VERSION will return the version number (only)
puts "Ruby version #{VERSION}"
···
On Jul 16, 2007, at 9:55 AM, Paul wrote:
I want to log the current Ruby version to a log file along with the
script version, but I don't know how to get the Ruby version from
within a running script.
I tried:
puts system("ruby -v")
but that only returns "true" from within a script. (I see the correct
output when I run it in IRB, but the script doesn't capture that.)
I also tried :
puts Config::CONFIG["ruby_version"]
I want to log the current Ruby version to a log file along with the
script version, but I don't know how to get the Ruby version from
within a running script.
I tried:
puts system("ruby -v")
but that only returns "true" from within a script. (I see the correct
output when I run it in IRB, but the script doesn't capture that.)
I also tried :
puts Config::CONFIG["ruby_version"]
but that returns "1.8" and I would like "1.8.x".
Any suggestions? Please let me know. Thanks.
You can try
puts(RUBY_VERSION)
By the way, if you need to get the output of an external command, you need to
use `cmd`, instead of system("cmd").