On Sat, 26 Aug 2006, bradjpeek wrote: > 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 the warning is from ruby. $VERBOSE = nil will shut it up if you want it shut up only sometimes do def quiet v = $VERBOSE yield ensure $VERBOSE = v end then x = quietly{ `tar tf mytar.tar` } print x > Any suggestions? if you really want fine control over stdin/stdout/stderr of executed commands check out my session and open4 libs http://codeforpeople.com/lib/ruby/session/session-2.4.0/README http://codeforpeople.com/lib/ruby/open4/open4-0.5.1/README in particular the Open4::spawn command. both are available as gem install session gem install open4 regards. -a -- to foster inner awareness, introspection, and reasoning is more efficient than meditation and prayer. - h.h. the 14th dalai lama