Rust 无法使用std::io::process::command执行'tput'命令

Rust 无法使用std::io::process::command执行'tput'命令,rust,tput,Rust,Tput,当我在终端中运行tput cols时,它会很好地打印出列数。但当我运行以下Rust程序时: use std::io::process::{Command, ProcessOutput}; fn main() { let cmd = Command::new("tput cols"); match cmd.output() { Ok(ProcessOutput { error: _, output: out, status: exit }) => {

当我在终端中运行
tput cols
时,它会很好地打印出列数。但当我运行以下Rust程序时:

use std::io::process::{Command, ProcessOutput};

fn main() {
    let cmd = Command::new("tput cols");
    match cmd.output() {
        Ok(ProcessOutput { error: _, output: out, status: exit }) => {
            if exit.success() {
                println!("{}" , out);
                match String::from_utf8(out) {
                    Ok(res)  => println!("{}" , res),
                    Err(why) => println!("error converting to utf8: {}" , why),
                }
            } else {
                println!("Didn't exit succesfully")
            }
        }
        Err(why) => println!("Error running command: {}" , why.desc),
    }
}
我得到以下错误:

Error running command: no such file or directory
有人知道为什么命令不能正确运行吗?为什么要查找文件或目录?

只使用要运行的命令的名称;可以使用添加参数


这确实解决了问题。现在我要做的就是提高产量。现在运行
tput
返回80,无论终端大小如何。
match Command::new("tput").arg("cols").output() {
    // …
}