Passing command line arguments to JRuby script

Hi all,

Have just started working with JRuby. I am writing this jruby script for
the SNMP management of the wireless equipment installed in my campus.
The way i have my script has 3 java classes corresponding to the 3 main
scripts that i have in ruby.Below i paste the code for the rum method of
one of my class categories (it just calls the corresponding ruby
script):

public void run() {
System.out.println(getName());
try {
ScriptEngineManager factory = new ScriptEngineManager();
// Create a JRuby engine.
ScriptEngine engine = factory.getEngineByName(“jruby”);
// Enable the JRuby script engine to invoke a script in a file.
Invocable inv = (Invocable) engine;
// Open a file reader on the external JRuby script file.
FileReader f = new
FileReader("/root/NetBeansProjects/java_thread_script_test/src/java_thread_script_test/cpeping.rb");
// Evaluate (execute) the script. Once evaluated, any functions
// in the script can be called with the invokeFunction method.
engine.eval(f);
}//end of try

Now, the problem is that i have made 3 classes and each of these classes
have to create 8 threads each (in java). so what i need is that i pass
on the IP Address and and an integer to the ruby script so that each
category (8 threads) can use the same ruby file instead of duplicating
the ruby scripts for individual threads.(WHICH IS THE MAIN PROBLEM THAT
I AM COMING ACROSS)

I guess this much detail will be enough to seek your help. Waiting for
your reply… Please do help me in this regard…

Thanks in advance…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs