Run other programs

J

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?
 
H

Harry

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"
 
J

Jonathan Denni

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"

thank you!
that was easy. so, according to
http://www.ruby-doc.org/docs/ProgrammingRuby/html/ref_m_kernel.html#Kernel.system
when I use system(" ") it has the same effect as if I typed whatever is
in the quotes into the terminal, right?

I could also use load("sub1.rb") instead of system("ruby sub1.rb")
correct?

Is there a way I can propogate the variables in the loaded files
('sub1.rb',sub2.rb') to the loading file ('main.rb')?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top