简体   繁体   中英

Rust - spawning a shell fails with an error

I am trying to execute a command within a shell using

let mut child = Command::new("ilorest")
    .stdin(Stdio::piped())
    .stdout(Stdio::piped())
    .spawn()
    .expect("ilorest command failed to start");

child
    .stdin
    .as_mut()
    .ok_or("Child process stdin has not been captured!")?
    .write_all(b"login HOST -u [USERNAME] -p [PASSWORD] \n 
    exit")?;

After executing this code, I am getting the error as

Traceback (most recent call last):
  File "rdmc.py", line 811, in <module>
  File "rdmc.py", line 315, in run
  File "rdmc.py", line 333, in cmdloop
  File "cliutils.py", line 194, in version
IOError: [Errno 22] Invalid argument
Failed to execute script rdmc

I am not able to understand where I am missing?

我得到了答案,我错过了代码

let output = child.wait_with_output().unwrap();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM