0

I am trying to pass a variable as a part of a bash command in my Rust program.

let speed_output = 70;
Command::new("nvidia-settings")
        .arg("-a")
        .arg("GPUTargetFanSpeed[fan:0]=speed_output")
        .spawn()
        .expect("nvidia-settings command failed to execute");

The program compiles correctly but my variable speed_output isn't passed to the bash shell. I would like to know how to pass variables from the Rust environment directly into the argument.

2
  • 1
    format!("GPUTargetFanSpeed[fan:0]={speed_output}") Commented Dec 29, 2022 at 23:03
  • 1
    This is not a bash command, since you’re not invoking bash at all; you’re spawning the process directly. Commented Dec 29, 2022 at 23:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.