Using C#, I'm creating and starting a process in order to read and parse its response. The process is a bash command that produces as output a json.
This json is then parsed and used in other portions of code.
StandardOutput is redirected and I'm able to read only a portion of it if it is too large. In this cases I'm unable to retrieve the missing portion to cuncatanate the strings and get a proper json.
My code:
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;
startInfo.FileName = "/bin/bash";
startInfo.Arguments = $"-c \"{i_Command.cmdLine}\"";
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = false;
startInfo.UseShellExecute = false;
foreach (KeyValuePair<string, string> var in i_Command.envVariables)
{
startInfo.EnvironmentVariables.Add(var.Key, var.Value);
}
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = startInfo;
process.Start();
string result = "";
if (process.StandardOutput != null)
{
result = process.StandardOutput.ReadToEnd();
}
process.WaitForExit();
The called bash command is an aws call, but I don't know if it is relevant to the issue, because with short outputs I'm not experiencing output truncation.
Let me know if you need more details, thanks in advance.