« Return to Thread: $stdout to printer

Re: $stdout to printer

by Bertram Scharpf :: Rate this Message:

Reply to Author | View in Thread

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/Germany
http://www.bertram-scharpf.de

 « Return to Thread: $stdout to printer