From: Shashank Date Date: 2003-01-30T16:41:08+09:00 Subject: Re: realtime display of stdout while using Kernel::backtick # Many ways to execute a shell-command STDOUT.sync = true cmd = 'ping -n 5 localhost' #'osql -Usa -Pdbmteam -S EMACHINE -d master -Q"select * from sysobjects" -n -h-1 -w 1000' # method 1 open("|#{cmd}") do |f| f.each{|line| print line} end # method 2 system("#{cmd}") # method 3 puts `#{cmd}` # method 4 IO.popen(cmd) do |p| p.each do |line| puts line end end "Kevin Moore" wrote in message news:hQ1_9.398$dL4.323583@newssrv26.news.prodigy.com... > Hello, > > I am using Ruby to develop an automatic build script at my company. We do > embedded development, and have three code bases that get built and nested > inside each other. (microcontrollers booting dsps in the box, and a GUI that > can update the box's code) > > So far the script is working great. If does just what I need, and the other > developers are impressed with the flexibility of the language. I have only > one problem: When I use the backtick operator (actually %x{}) I can capture > that stdout output, but I can't display it in real time (as the external > program prints it) > > I am doing something like this: > > puts(%x{#{some_compilicated_pvcs_command_string}}) > > This drives PVCS quite well. It checks out all ( >200) my files and prints a > message listing each file that it checks out. Unfortunately, all the text > spews out at once! When the tool is invoked directly from the command line, > the text comes one line at a time, synchronous with the checkouts. > > I am running the _very_ impressive Win32 distribution (version 1.6.8-8) from > the Pragmatic Programmer site. > > Is there a way to set up Ruby to send the output of the tool to the console > as it comes in? Any advice would be greatly appreciated! > > This is a fantastic language. I can't wait to do more with it! > > Kevin M. > >