Skip to content

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

@torstello

Description

@torstello

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions