Inside a ruby script I want to:

1)  redirect STDERR to /dev/null
2)  Issue a system call (e.g. system(tar xf tarfile file) )
3)  revert to normal STDERR output

I have a script that issues 3-4 system calls that are returning the
following message to STDERR:

warning: Insecure world writable dir /opt, mode 040777

I'd like to suppress these messages (Let's assume that I can't change
the permissions on /opt).

An example of one of the lines that is throwing the error is:

x = `tar tf mytar.tar`   #  envoke the unix tar command
print x

I can suppress the messages by:

$stderr.reopen('/dev/null', 'w')            # send STDERR to /dev/null
STDERR.puts "can you see me?"    #  message is suppressed

But I haven't been able to figure out how to revert STDERR back to
before the the reopen.  I only want to suppress this particular
message, but not others that may prove to be useful such as error
messages from the ruby interpreter.

I've tried variations of:

stderr = $stderr                 # save current STDERR IO instance
$stderr.reopen('/dev/null', 'w') # send STDERR to /dev/null
STDERR.puts "can you see me?"    #  message is suppressed
$stderr.reopen(stderr)           # revert to default behavior  (doesn't
work)
STDERR.puts "what about me?      #  I want to see this but I don't

Any suggestions?