hiding system command results in ruby hiding system command results in ruby ruby ruby

hiding system command results in ruby


You can use the more sophisticated popen3 to have control over STDIN, STDOUT and STDERR separately if you like:

Open3.popen3("curl...") do |stdin, stdout, stderr, thread|  # ...end

If you want to silence certain streams you can ignore them, or if it's important to redirect or interpret that output, you still have that available.


To keep it working with system without modifying your command:

system('curl ...', :err => File::NULL)

Source


Easiest ways other than popen:

  1. Use %x instead of system. It will automatically pipe

    rval = %x{curl ...}       #rval will contain the output instead of function return value
  2. Manually pipe to /dev/null. Working in UNIX like system, not Windows

    system "curl ... > /dev/null"