# Starting multiple processes

**URL:** <https://www.ruby-forum.com/t/starting-multiple-processes/123719>\
**Category:** Ruby\
**Created:** [December 20, 2007, 12:30am UTC](https://www.ruby-forum.com/t/starting-multiple-processes/123719 "2007-12-20T00:30:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 20, 2007, 12:30am UTC](https://www.ruby-forum.com/t/starting-multiple-processes/123719/1 "2007-12-20T00:30:46Z")

</div>

hello  
i have to do the following

1. 

```
exec("E:\\TradingTools\\IBController\

```

\IBControllerStart\_customised.bat")  
2. application = WIN32OLE.new(“Broker.Application”)

I want to start 1 and then continue doing 2. however when i run it  
realtime, the statement 2 waits for statement 1 to be completed which  
takes long time. how do i initiate 1 and then withotu waiting goto  
statement 2.

apreciate ur help

seede

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 20, 2007, 12:53am UTC](https://www.ruby-forum.com/t/starting-multiple-processes/123719/2 "2007-12-20T00:53:38Z")

</div>

Junkone wrote:

> hello  
> i have to do the following
> 
> 1. 
> 
> ```
> exec("E:\\TradingTools\\IBController\
> 
> ```
> 
> \IBControllerStart\_customised.bat")  
> 2. application = WIN32OLE.new(“Broker.Application”)
> 
> I want to start 1 and then continue doing 2. however when i run it  
> realtime, the statement 2 waits for statement 1 to be completed which  
> takes long time. how do i initiate 1 and then withotu waiting goto  
> statement 2.

Wrap #1 in a thread:

Thread.new do  
exec(…)  
end

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 20, 2007, 9:35am UTC](https://www.ruby-forum.com/t/starting-multiple-processes/123719/3 "2007-12-20T09:35:15Z")

</div>

2007/12/20, Joel VanderWerf [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > statement 2.
> 
> Wrap #1 in a thread:
> 
> Thread.new do  
> exec(…)  
> end

Wouldn’t help. This is #exec and not #system - the process does not  
wait, it is completely replaced and “application =  
WIN32OLE.new(“Broker.Application”)” is never executed.

You rather want fork.

fork do  
exec …  
end

Cheers

robert

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 20, 2007, 4:32pm UTC](https://www.ruby-forum.com/t/starting-multiple-processes/123719/4 "2007-12-20T16:32:48Z")

</div>

On Dec 20, 2007 2:34 AM, Robert K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > takes long time. how do i initiate 1 and then withotu waiting goto  
> > > WIN32OLE.new(“Broker.Application”)" is never executed.
> 
> –  
> use.inject do |as, often| as.you\_can - without end

Fork isn’t implemented on Windows. Try this:

system(“start  
E:\TradingTools\IBController\IBControllerStart\_customised.bat”)  
application = WIN32OLE.new(“Broker.Application”)

-Gordon

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 20, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/starting-multiple-processes/123719/5 "2007-12-20T17:06:12Z")

</div>

2007/12/20, Gordon T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > > > realtime, the statement 2 waits for statement 1 to be completed which  
> > > > wait, it is completely replaced and "application =  
> > > > robert
> > 
> > –  
> > use.inject do |as, often| as.you\_can - without end
> 
> Fork isn’t implemented on Windows.

Unless you are using cygwin. Sorry, I keep forgetting that the other  
Windows based versions do not have it. Thanks for correcting me!

> Try this:
> 
> system(“start E:\TradingTools\IBController\IBControllerStart\_customised.bat”)  
> application = WIN32OLE.new(“Broker.Application”)

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 22, 2007, 1:50am UTC](https://www.ruby-forum.com/t/starting-multiple-processes/123719/6 "2007-12-22T01:50:57Z")

</div>

On Dec 21, 2:55 pm, Joel VanderWerf [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > > realtime, the statement 2 waits for statement 1 to be completed which  
> > > > WIN32OLE.new(“Broker.Application”)" is never executed.
> 
> This is AFAIK platform independent, since it doesn’t (explicitly,  
> anyway) use #fork or “start”.
> 
> –  
> vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407- Hide quoted text -
> 
> - Show quoted text -

i tried that. it does not work for me. it waits  
Thread.new do  
system(“start E:\TradingTools\IBController  
\IBControllerStart\_customised.bat”)  
end  
to get completed before going and doing this  
application = WIN32OLE.new(“Broker.Application”)

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 20, 2007, 4:46pm UTC](https://www.ruby-forum.com/t/starting-multiple-processes/123719/7 "2007-12-20T16:46:52Z")

</div>

Maynot help you much but in Perl world I used IPC::Run module to do exactly this. Not sure if there is a similar module in RubyLand.  
  
Gordon T. wrote:

> ```
> On Dec 20, 2007 2:34 AM, Robert K.[\<removed\_email\_address@domain.invalid\>](mailto:removed_email_address@domain.invalid)wrote:
> ```
> 
> > ```
> > 2007/12/20, Joel VanderWerf[\<removed\_email\_address@domain.invalid\>](mailto:removed_email_address@domain.invalid):
> > ```
> > 
> > > ```
> > > Junkone wrote:
> > > ```
> > > 
> > > > ```
> > > > hello
> > > > i have to do the following
> > > > 1. exec("E:\\TradingTools\\IBController\
> > > > \IBControllerStart_customised.bat")
> > > > 2. application = WIN32OLE.new("Broker.Application")
> > > > 
> > > > I want to start 1 and then continue doing 2. however when i run it  
> > > > realtime, the statement 2 waits for statement 1 to be completed which  
> > > > takes long time. how do i initiate 1 and then withotu waiting goto  
> > > > statement 2.
> > > > ```
> > > 
> > >   
> > > 
> > > ```
> > > Wrap#1in a thread:
> > > 
> > > Thread.new do  
> > > exec(…)  
> > > end
> > > ```
> > 
> >   
> > 
> > ```
> > Wouldn’t help. This is#execand not#system- the
> > process does not
> > wait, it is completely replaced and “application =
> > WIN32OLE.new(“Broker.Application”)” is never executed.
> > 
> > You rather want fork.
> > 
> > fork do  
> > exec …  
> > end
> > 
> > Cheers
> > 
> > robert
> > 
> > –  
> > use.inject do |as, often| as.you\_can - without end
> > 
> > ```
> > </pre>
> > 
> > ```
> > ```
> 
> ```
> Fork isn’t implemented on Windows. Try this:
> 
> system(“start  
> E:\TradingTools\IBController\IBControllerStart\_customised.bat”)  
> application = WIN32OLE.new(“Broker.Application”)
> 
> -Gordon
> ```

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 21, 2007, 8:56pm UTC](https://www.ruby-forum.com/t/starting-multiple-processes/123719/8 "2007-12-21T20:56:30Z")

</div>

Robert K. wrote:

> > > takes long time. how do i initiate 1 and then withotu waiting goto  
> > > statement 2.  
> > > Wrap #1 in a thread:
> > 
> > Thread.new do  
> > exec(…)  
> > end
> 
> Wouldn’t help. This is #exec and not #system - the process does not  
> wait, it is completely replaced and “application =  
> WIN32OLE.new(“Broker.Application”)” is never executed.

Oops, you’re quite right, I was thinking of #system.

Maybe #system would be right for the OP:

Thread.new do  
system("…")  
end

application = …

This is AFAIK platform independent, since it doesn’t (explicitly,  
anyway) use #fork or “start”.
