In python, I can execute a shell script/command by doing this.
import os
os.system('echo hello')
This code will yield the expected output, hello from stdout, and exit code of 0. But when I try to execute commands from rust or dart, commands like echo and ls won't work.
// rust
Command::new("echo")
.arg("hello")
.spawn()
.expect("echo command failed to start");
// dart
await Process.run('echo', ['hello'])
Both of these will yield binary file/command not found errors. Why is that? I am simply looking for an equivalent of python's system function in both of these languages.
I don't think it is because of the OS used. Because even if ls don't wok on windows, echo should. I tested both dir and ls because I was worried it is about OS, but none of them worked.