From: "Peña, Botp" Date: 2007-01-30T12:25:37+09:00 Subject: Re: Run other programs From: Harry [mailto:ruby.hardware@gmail.com]: # From Jonathan Denni : # > lets say I have three programs # > # > Main.rb # > Sub1.rb # > and # > Sub2.rb # > # > When I run Main.rb, I want it to access and run the other two ruby # > programs. How do I do this? # > # # If you just want to run them one at a time and wait, you can do this; # # trya.rb # puts "a" # sleep 3 # system("ruby tryb.rb") # system("ruby tryc.rb") # sleep 3 # # tryb.rb # puts "b" # sleep 3 # # tryc.rb # puts "c" Just in case, he's not familiar w ruby's require yet. C:\family\ruby>cat main.rb puts __FILE__ require 'sub1.rb' require 'sub2.rb' C:\family\ruby>cat sub1.rb puts __FILE__ C:\family\ruby>cat sub2.rb puts __FILE__ C:\family\ruby>ruby main.rb main.rb ./sub1.rb ./sub2.rb C:\family\ruby>qri require ------------------------------------------------------ Multiple choice Kernel#require, Needle::Container#require, Needle::DefinitionContext#require C:\family\ruby>qri kernel#require --------------------------------------------------------- Kernel#requi require(string) => true or false ---------------------------------------------------------------------- Ruby tries to load the library named _string_, returning +true+ i successful. If the filename does not resolve to an absolute path, it will be searched for in the directories listed in +$:+. If the file has the extension ``.rb'', it is loaded as a source file; if the extension is ``.so'', ``.o'', or ``.dll'', or whatever the default shared library extension is on the current platform, Ruby loads the shared library as a Ruby extension. Otherwise, Ruby tri adding ``.rb'', ``.so'', and so on to the name. The name of the loaded feature is added to the array in +$"+. A feature will not loaded if it's name already appears in +$"+. However, the file na is not converted to an absolute path, so that ``+require 'a';require './a'+'' will load +a.rb+ twice. hth kind regards -botp