From: Aditya Mahajan Date: 2007-10-15T04:51:11+09:00 Subject: Re: Capturing the output of an external program line by line Tim Hunter wrote: > Aditya Mahajan wrote: >> Thanks, >> Aditya >> > I've been using this: > > IO.popen("#{cmd} 2>&1") do |f| > while line = f.gets do > # do whatever you want with line > end > end > > Note that this gets both stdout and stderr. Thank you Tim and Markus. Both your methods work perfectly. Since I just needed to capture the program's output, I am using Tim's method. Thanks, Aditya -- Posted via http://www.ruby-forum.com/.