This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -9,7 +10,7 @@ namespace AyaNova.Util
|
||||
{
|
||||
|
||||
|
||||
public static string Run(string cmd, string arguments, ILogger log = null)
|
||||
public static string Run(string cmd, List<string> arguments, ILogger log = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -45,7 +46,7 @@ namespace AyaNova.Util
|
||||
|
||||
|
||||
|
||||
private static string RunWindows(string cmd, string arguments)
|
||||
private static string RunWindows(string cmd, List<string> arguments)
|
||||
{
|
||||
/*
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
@@ -81,13 +82,15 @@ process.BeginOutputReadLine();
|
||||
process.StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = cmd,
|
||||
Arguments = arguments,
|
||||
// Arguments = arguments,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
};
|
||||
|
||||
foreach (string s in arguments)
|
||||
process.StartInfo.ArgumentList.Add(s);
|
||||
process.Start();
|
||||
|
||||
string result = $"{process.StandardOutput.ReadToEnd()}{process.StandardError.ReadToEnd()} ";
|
||||
@@ -96,7 +99,7 @@ process.BeginOutputReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
private static string RunLinuxBash(string cmd, string arguments)
|
||||
private static string RunLinuxBash(string cmd, List<string> arguments)
|
||||
{
|
||||
var escapedArgs = $"{cmd} {arguments}".Replace("\"", "\\\"");
|
||||
|
||||
@@ -105,11 +108,13 @@ process.BeginOutputReadLine();
|
||||
process.StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "/bin/bash",
|
||||
Arguments = $"-c \"{escapedArgs}\"",
|
||||
// Arguments = $"-c \"{escapedArgs}\"",
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
};
|
||||
foreach (string s in arguments)
|
||||
process.StartInfo.ArgumentList.Add(s);
|
||||
|
||||
process.Start();
|
||||
string result = process.StandardOutput.ReadToEnd();
|
||||
@@ -119,18 +124,21 @@ process.BeginOutputReadLine();
|
||||
}
|
||||
|
||||
|
||||
private static string RunOSX(string cmd, string arguments)
|
||||
private static string RunOSX(string cmd, List<string> arguments)
|
||||
{
|
||||
using (var process = new Process())
|
||||
{
|
||||
process.StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = cmd,
|
||||
Arguments = arguments,
|
||||
|
||||
// Arguments = arguments,
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
};
|
||||
foreach (string s in arguments)
|
||||
process.StartInfo.ArgumentList.Add(s);
|
||||
|
||||
process.Start();
|
||||
string result = process.StandardOutput.ReadToEnd();
|
||||
|
||||
Reference in New Issue
Block a user