dmatrix00d
6/30/2006 2:33:00 PM
this might be a stupid reply, but how come
system ("python example.py) works?
it prints
hello
(wait 10 seconds)
world.
i just want the effects of that, but do something with that print
statement
thanks
Erich Lin wrote:
> The example was just an example. I mainly want to be able to run any
> program (not just a python program), and still intercept the print
> statements and do something with them.
>
> Thanks,
>
> Sorry for the confusion
>
> ts wrote:
> > >>>>> "d" == dmatrix00d <dmatrix00d@gmail.com> writes:
> >
> > d> and it does everything except , it waits the 10 seconds before it
> > d> begins processing so it is not interactive
> >
> > Well the problem is in the P language, fatally :-)
> >
> > Seriously, with these scripts
> >
> > moulon% cat b.rb
> > #!/usr/bin/ruby
> > IO.popen("ruby c.rb") do |p|
> > p.each do |line|
> > puts line + "foo"
> > end
> > end
> > moulon%
> >
> > moulon% cat c.rb
> > #!/usr/bin/ruby
> > puts "hello"
> > sleep(10)
> > puts "word"
> > moulon%
> >
> > You'll have the same result, but if you change the script c.rb to add
> > 'stdout.sync = true' it will work as expected
> >
> > moulon% cat c.rb
> > #!/usr/bin/ruby
> > $stdout.sync = true
> > puts "hello"
> > sleep(10)
> > puts "word"
> > moulon%
> >
> > this mean that, in your case, the problem is with the python script not
> > with ruby.
> >
> >
> > --
> >
> > Guy Decoux