From: Gilbo Date: 2009-07-08T21:00:09+09:00 Subject: Re: $stdout to printer On Jul 7, 2:32 pm, Bertram Scharpf wrote: > Hi, > > Am Dienstag, 07. Jul 2009, 20:10:53 +0900 schrieb Brian Candler: > > > (1) File.open("prn:","w") { |f| ... } > > (2) IO.popen("print","w") { |f| ... } > > The original question was how to redirect $stdout. > >   def print_it >     IO.popen "lpr -o some_option", "w" do |f| >       $stdout = f >       yield >     end >   ensure >     $stdout = STDOUT >   end > > Sorry, I can only test and will only provide the UNIX version. > > Bertram > > -- > Bertram Scharpf > Stuttgart, Deutschland/Germanyhttp://www.bertram-scharpf.de Not sure about redirecting stdout on windows, best i can see is that you redirect to a temp file and print that. if the file is a recognised type on windows (e.g. .pdf and adobe reader is installed) try this : require 'win32ole' SHELL_APP = WIN32OLE.new('Shell.Application') SHELL_APP.ShellExecute("test.pdf", '', "C:\\Temp", 'print', 0) otherwise you can try printing to a shared network printer: PRINTER = "\\\\192.168.1.1\\shared_printer" system "print /d:#{PRINTER} C:\\Temp\\test.txt"