Running system() and suppressing errors

Hi,

Simple question.

Say I do this from a .rb script:

system “gedit README”

Right now I get a warning:

Gtk-WARNING **: Locale not supported by C library.Using the fallback
‘C’ locale.

I don’t want or need this warning.

Is there a way to suppress it completely?

I tried by:

system “gedit README 2>&1”

To no avail.

Any ideas?

On Sunday 07 August 2011 23:23:05 Marc H. wrote:

Gtk-WARNING **: Locale not supported by C library.Using the fallback
To no avail.

Any ideas?

Redirecting stderr to stdout won’t solve your problem, as system prints
stdout
on screen (unlike the backtick operator which stores the output in a
variable). To avoid displaying it, you should redirect it to /dev/null.

system “gedit README 2>/dev/null”

I hope this helps

Stefano

Marc -

You got that same error running gedit directly from the command line,
didn’t you? I don’t think it would behave any differently run from
Ruby, would it?

  • Keith

Indeed, that solved my problem.

Thank you!