Getting output of program with some DRb for good measure

  • Thread starter Christopher Dancy
  • Start date
C

Christopher Dancy

I'm running a DRb service which accepts a string<file name> and than
processes that file name on the server side. So I've been digging around
the internet and it seems people have been running into the same
problems as me. The DRb service will execute the file ... but doing so
will block the DRb service until IO.popen is finished. A way of getting
around this is to put the executing IO.popen block into a thread ...
which does work. The problem comes when printing to standard out ... it
wont.

IO.popen("#{command_string}","w+") do |ant_output|
Thread.new {
ant_output.each do |line|
puts line
end
}
end

I need the output of the given program being run to be printed to the
screen and I can't seem to figure it out... any suggestions?
 
C

Christopher Dancy

Christopher said:
I'm running a DRb service which accepts a string<file name> and than
processes that file name on the server side. So I've been digging around
the internet and it seems people have been running into the same
problems as me. The DRb service will execute the file ... but doing so
will block the DRb service until IO.popen is finished. A way of getting
around this is to put the executing IO.popen block into a thread ...
which does work. The problem comes when printing to standard out ... it
wont.

IO.popen("#{command_string}","w+") do |ant_output|
Thread.new {
ant_output.each do |line|
puts line
end
}
end

I need the output of the given program being run to be printed to the
screen and I can't seem to figure it out... any suggestions?

I've narrowed down the problem a bit ... it seems I get the output from
within the thread but not from within the ant_ouput block. So if I do
something like ..

IO.popen("#{command_string}","w+") do |ant_output|
Thread.new {
puts "hello world"
ant_output.each do |line|
puts "fish sticks"
puts line
end
}
end

I do get the "hello world" but not the "fish sticks" ... I've tried
passing the ant_output block to the thread but still nothing.
 
B

Brian Candler

You're using Windows, I guess? I would be very surprised if DRb blocks
in this way under Linux.
 
C

Christopher Dancy

Brian said:
You're using Windows, I guess? I would be very surprised if DRb blocks
in this way under Linux.

Yes I am using windows as well as various version of unix. I'm testing
it on windows ... if I can get it running on windows than everything
else is a piece of cake.
 

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,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top