小编Hea*_*low的帖子

如何将子进程输出重定向到stderr?

我正在尝试使用CommandAPI 启动进程并将其标准输出重定向到标准错误.以下失败:

Command::new("tput").arg("rc")
    .stdout(io::stderr())
    .status()
    .expect("failed to run tput");
Run Code Online (Sandbox Code Playgroud)

因为Command::new("tput").arg("rc").stdout(<XXX>)期望std::process::Stdio:

expected struct `std::process::Stdio`, found struct `std::io::Stderr`
Run Code Online (Sandbox Code Playgroud)

Bash中的等价物可能是tput rc > /dev/stderr.

我想知道如何正确地做到这一点.

io-redirection rust

9
推荐指数
1
解决办法
607
查看次数

标签 统计

io-redirection ×1

rust ×1