Created
September 12, 2012 02:51
-
-
Save lucasdavila/3703950 to your computer and use it in GitHub Desktop.
Calling a jruby script from a ruby script (via shell)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $jruby_bin = '/path/to/jruby/bin/jruby' | |
| $children_script = File.join File.expand_path('.'), 'children.rb' | |
| def call_children command = '' | |
| full_command = "#{$jruby_bin} -r#{$children_script} -e '#{command}'" | |
| puts "Executing command: #{full_command}" | |
| system full_command | |
| end | |
| puts "Hello from parent!" | |
| call_children "say_hello" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'java' | |
| def say_hello | |
| java.lang.System.out.println "Hello from children!" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Running "$ ruby parent.rb", will display: | |
| Hello from parent! | |
| Executing command: /path/to/jruby -r/path/to/children.rb -e 'say_hello' | |
| Hello from children! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment