Hello, I''m trying to write a utility to run an external process and capture it''s stderr. It seems that IO.popen only lets me read the stdout. Any tips for how to read stderr? Mike snippet of code... def process_file(filename) @filename = filename puts "Processing: " + @filename cmdline = "ffmpeg -i " + @filename ffmpeg = IO.popen(cmdline, "w+") ffmpeg.close_write result = ffmpeg.gets result.each do |line| puts "Line from ffmpeg: " + line end end This code does not work because the good stuff I want from ffmpeg went to stderr and not stdout. Please refrain from commenting on the merits of ffmpeg. That could go on all day. :-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hello again, No takers so far... I tried this: IO.popen(cmdline, "w+") { |f| puts f.gets } and the command executes but my silly command (fffmpeg) writes all the good stuff to stderr. I grep''ed the source for ffmpeg and there are : $ grep -r fprintf.stderr * | wc 284 2271 25075 way to many for me to want to change. Is there some cool command line trick to map stderr to stdout? Thanks for any help... Mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This has probably long-been resolved for you, but for others who end up here hoping for the answer.. You can just stick "2>&1" in the argument to IO.popen after your command, like so: ffmpeg = IO.popen(cmdline + " 2>&1", "w+") -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---