Page 1 of 1

Ich erhalte einen Binärdateifehler, wenn ich einen Bash -Befehl von C# ausführen kann

Posted: 23 Apr 2025, 10:51
by Anonymous
Ich habe einen Discord -Bot erstellt, mit dem Sie interagieren können (ausgeführt auf einem Raspberry Pi mit einem Standard -Himbeer -Pi -Betriebssystem). Ich habe auch einen Befehl hinzugefügt, um einen Shell -Befehl auszuführen. Mein Code: < /p>

Code: Select all

        ProcessStartInfo inf = new()
{
CreateNoWindow = true,
RedirectStandardError = true,
RedirectStandardOutput = true,
RedirectStandardInput = true,
FileName = "/bin/bash",
Arguments = command,
};
if (Process.Start(inf) is Process cmd)
{
string ret = "Output: " + await cmd.StandardOutput.ReadToEndAsync();
ret += "\nError Output: " + await cmd.StandardError.ReadToEndAsync();
await Program.Log(ret);
return ret;
}
Wenn ich den Befehl auf echo Hallo, World! Ich erhalte den folgenden Fehler im StandardOutput:

/usr/bin/echo:/usr/bin/echo: kann nicht ausführen.>