-
Notifications
You must be signed in to change notification settings - Fork 13
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
how to get stderr #43
Labels
question
Further information is requested
Comments
Hi @RickSKy As far as I understand the question you what to read from
use std::process::Stdio;
use expectrl::{Error, Session, WaitStatus};
fn main() -> Result<(), Error> {
let mut cmd = std::process::Command::new("sh");
cmd.arg("-c").arg("echo print to stdout && echo print to stderr >&2");
// turn off stdout
cmd.stdout(Stdio::null());
let mut p = Session::spawn(cmd)?;
let line = p.expect('\n')?;
println!("{:?}", String::from_utf8_lossy(line.as_bytes()));
let line = p.expect('\n')?;
println!("{:?}", String::from_utf8_lossy(line.as_bytes()));
assert_eq!(p.wait().unwrap(), WaitStatus::Exited(p.pid(), 0));
Ok(())
} Am I addressed you question? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there any example to get stderr for expect?
The text was updated successfully, but these errors were encountered: