Skip to content

Handling stderr from a client #258

Answered by Eugeny
spoutn1k asked this question in Q&A
Discussion options

You must be logged in to vote

You're on the right track - stderr data will arrive as ExtendedData with ext=1.

As an example, you can add this to the event loop in the client_exec_simple example:

                ChannelMsg::ExtendedData { ref data , ..} => {
                    print!("<stderr>:");
                    stdout.write_all(data).await?;
                    stdout.flush().await?;
                }

and it will work:

cargo run --all-features --example client_exec_simple -- --private-key ... 192.168... bash -c "echo stderr > /dev/stderr; echo stdout > /dev/stdout"
   Compiling russh v0.43.0-beta.1 (/Users/eugene/Work/russh/russh)
    Finished dev [unoptimized + debuginfo] target(s) in 0.99s
[2024-03-04T13:24:1…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@spoutn1k
Comment options

Answer selected by spoutn1k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants