Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rust 生锈-生成外壳失败并出现错误_Rust - Fatal编程技术网

Rust 生锈-生成外壳失败并出现错误

Rust 生锈-生成外壳失败并出现错误,rust,Rust,我试图在shell中使用 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 proces

我试图在shell中使用

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")?;
执行此代码后,我得到的错误如下

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
回溯(最近一次呼叫最后一次):
文件“rdmc.py”,第811行,在
文件“rdmc.py”,第315行,正在运行
cmdloop中第333行的文件“rdmc.py”
文件“cliutils.py”,第194行,版本
IOError:[Errno 22]参数无效
无法执行脚本rdmc

我无法理解我丢失了什么?

我得到了答案,我丢失了代码

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

嗨,哈希特。您的示例中似乎遗漏了一些内容。如果您能提供更多关于
ilorest
的信息就更好了,因为python文件中的错误看起来与您的代码无关。作为另一种解决方案,您可以尝试从rust代码启动一些简单的bash脚本。