Thermatix
Thermatix

Reputation: 2929

How to turn off $stdout and $stderr in Ruby

Is it possible to turn off $stdout and $stderr and not re-direct it to a file; just turn it off so it prints out nothing to anywhere?

I've already tried the following code, but it just errors with error: Invalid argument

$stderr = IO.new(0,"w")
$stdout = IO.new(0,"w")

Upvotes: 1

Views: 1440

Answers (1)

Michael Chaney
Michael Chaney

Reputation: 3041

This gist will show you how to redirect to /dev/null:

https://gist.github.com/moertel/11091573

Or this SO answer:

How do I redirect stderr and stdout to file for a Ruby script?

Your question probably needs to be marked as a dup.

Upvotes: 5

Related Questions