Files
FA/DevelopmentAgent/Shell/ShellRunner.cs
Piotr Kus 8eeb6389df
All checks were successful
ci/woodpecker/push/push_to_repo Pipeline was successful
* Created DevelopmentAgent to generate automaticaly UnitTests for projects
2026-01-25 11:27:49 +01:00

35 lines
931 B
C#

using System.Diagnostics;
namespace DeploymentAgent.Shell;
public class ShellRunner : IShellRunner
{
public (int ExitCode, string StdOut, string StdErr) RunScript(string script)
{
var psi = new ProcessStartInfo
{
FileName = "/bin/sh",
Arguments = "-s",
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
};
using var process = new Process();
process.StartInfo = psi;
process.Start();
process.StandardInput.WriteLine(script);
process.StandardInput.Close();
var output = process.StandardOutput.ReadToEnd();
var error = process.StandardError.ReadToEnd();
process.WaitForExit();
return (process.ExitCode, output, error);
}
}