Run other programs

Discussion in 'Ruby' started by Jonathan Denni, Jan 25, 2007.

  1. 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?

    --
    Posted via http://www.ruby-forum.com/.
    Jonathan Denni, Jan 25, 2007
    #1
    1. Advertising

  2. Jonathan Denni

    Harry Guest

    On 1/26/07, Jonathan Denni <> wrote:
    > 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"

    --
    http://www.kakueki.com/ruby/list.html
    Harry, Jan 30, 2007
    #2
    1. Advertising


  3. > 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')?

    --
    Posted via http://www.ruby-forum.com/.
    Jonathan Denni, Jan 30, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. robin
    Replies:
    0
    Views:
    843
    robin
    Jul 20, 2003
  2. Replies:
    12
    Views:
    1,612
    Dave Thompson
    Jan 10, 2005
  3. Dagorlas
    Replies:
    7
    Views:
    366
    Dagorlas
    Jun 16, 2006
  4. Frog
    Replies:
    10
    Views:
    569
    Michal Dzirba
    Nov 24, 2003
  5. Coca
    Replies:
    7
    Views:
    721
    Aidan Grey
    Aug 24, 2004
Loading...

Share This Page