Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot 'switch off' stderr output of remote ssh command execution #65

Open
torstello opened this issue Sep 2, 2015 · 2 comments
Open

Comments

@torstello
Copy link

Hi Delano,

maybe you can direct me to a solution; i don't manage to suppress the printing to STDERR when a remote cmd fails (like date --foobar).
(I'm collecting and further process the output of rye::set / rye::box commands)

I tried last with this rye_opts:

    RYE_OPTS   = { 
                  :error           => false,
                  :verbose      => Logger::FATAL,  # this was a try after reading Net::SSH.start docs
                  :safe            => false,
                  :quiet           => true,
                  :password_prompt => false }

but it always prints the cmd error to $stderr:

D, [#73533] DEBUG -- : host_exec(host='lxt', cmd='date -I --foo', params='', u='', dry='false'
D, [#73533] DEBUG -- : Tmt::RyeCmdExec.get_rye_box(lxt, {:error=>false, :verbose=>4, :safe=>false, :quiet=>true, :password_prompt=>false})
D, [#73533] DEBUG -- host_exec: rye_box.execute('date -I --foo', '')
>>>>>>
date: unrecognized option '--foo'
Try `date --help' for more information.
<<<<<<<
D, [#73533] DEBUG -- : calling format_output with => [, date: unrecognized option '--foo'; Try `date --help' for more information., 1, ]

The only way that really works is redirect the stderr of my cli program like this tmt host -h testserver date -- --foo 2>/dev/null

But of course that's not a solution.

Any hint is very much appreciated!

@torstello
Copy link
Author

I also tried:

    io_trash = File.open(File::NULL, 'w')
    RYE_OPTS   = { 
                    :error           => io_trash,
    io_trash = File.open('/dev/null', 'w')
    RYE_OPTS   = { 
                    :error           => io_trash,
    io = StringIO.new('dontbotherme')
    RYE_OPTS   = { 
                  :error           => io,

with all this, the error still ends up on STDERR.
The only thing that changed it was :error => STDOUT

@torstello
Copy link
Author

i didn't want to close this issue :)

@torstello torstello reopened this Sep 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant