You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I understand the question you what to read from stderr right?
expect reads from stdout and stderr simultaneously so there's only 1 way I know how to do it.
You need to turn of stdout.
See this example.
use std::process::Stdio;use expectrl::{Error,Session,WaitStatus};fnmain() -> Result<(),Error>{letmut 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());letmut 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(())}
Is there any example to get stderr for expect?
The text was updated successfully, but these errors were encountered: