0

Possible Duplicate:
Pass variables to ruby script via command line

I am trying to pass the HOSTNAME as a parameter into a ruby script. Is this possible? This is what I believe should work, but it doesn't.

%h% = HOSTNAME
ECHO %h%

ruby this.rb %h%
pause

And the ruby code is

val = ARGV[0]

puts "Value is #{val}"
Community
  • 1
  • 1
Andrew
  • 5,215
  • 1
  • 23
  • 42

1 Answers1

0

You could set an environment variable in DOS and access it from your Ruby script. It would be something like:

set h = HOSTNAME
ECHO %h%

ruby this.rb
pause

Ruby code:

val = ENV["h"]

puts "Value is #{val}"
Eric Levine
  • 13,536
  • 5
  • 49
  • 49
  • I was trying to avoid that. The actual script with the problem was : ruby replace_text.rb myfile.csv A_Computer_Name HOSTNAME – Andrew Aug 01 '12 at 13:09