# Thread to handle an execute command and wait for output

**URL:** <https://www.ruby-forum.com/t/thread-to-handle-an-execute-command-and-wait-for-output/186819>\
**Category:** Ruby\
**Created:** [April 12, 2010, 11:21pm UTC](https://www.ruby-forum.com/t/thread-to-handle-an-execute-command-and-wait-for-output/186819 "2010-04-12T23:21:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![woow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7bcc69/32.png) [@woow](https://www.ruby-forum.com/u/woow)\
**Post date:** [April 12, 2010, 11:21pm UTC](https://www.ruby-forum.com/t/thread-to-handle-an-execute-command-and-wait-for-output/186819/1 "2010-04-12T23:21:07Z")

</div>

Hi,

I am struggling to do following,

1. I want to execute a client on command line and wait for a  
output…(myClient)

2. execute another command which will make the above client output  
something…  
(grabtest /VERSION)

3. Grab the output from the client…and do something…

I have following but it does not work…pls help.

a = Thread.new {  
@cmdOut = @machine.operations.runCommand("/opt/nc/test/myClient -o  
1");  
Thread.pass;  
print"@cmdOut = #{@cmdOut}"  
}  
b = Thread.new {  
@machine2 = Machine.new(:D0, {:hostname =\> @hostname,  
:logger =\> @log, :acquireDelay =\> @IDelay,  
:markDelay =\> @markIDelay});

```
  @cmdOut1 = @machine2.operations.runCommand("grabtest /VERSION");
  print"@cmdOut1 = #{@cmdOut1}"
  Thread.pass

```

}

```
b.join

```

Thanks in advance
