Greg said:
I can't find out how can I execute my ruby script from another ruby
file.
This is how I would do it in command line
ruby jobs/eventParser.rb "5454353"
system "ruby", "jobs/eventParser.rb", "5454353"
system "ruby jobs/eventParser.rb 5454353"
The latter is less secure since it passes the string to a shell for
splitting into words, and you have to worry about things like quoting,
but it lets you do redirection and shell pipelines, e.g.
system "ruby jobs/eventParser.rb 5454353 2>/dev/null"
However, it may be an idea to try to write your ruby code in such a way
as it could be used directly from the first ruby program. Then it might
become:
require 'jobs/eventParser'
EventParser.new.run("5454353")
This is more efficient because you don't spawn a whole new ruby
interpreter, and becomes even more efficient if you are repeatedly using
the EventParser object.
jobs/eventParser.rb can be written in such a way as it will work both
ways:
class EventParser
def run(args)
...
end
end
if __FILE__ == $0
EventParser.new.run(ARGV)
end
HTH,
Brian.