Blog/Contracts/Api/Ebasher.cs
2024-01-17 01:08:20 +03:00

25 lines
No EOL
610 B
C#

using System.Diagnostics;
namespace Api;
public static class Ebasher
{
public static string Bash(this string cmd)
{
cmd = cmd.Replace("\"", "\\\"");
var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "bin/bash",
Arguments = $"-c \"{cmd}\"",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
proc.Start();
proc.WaitForExit();
return proc.StandardOutput.ReadToEnd();
}
}