I'm trying to run the command line utility PCLI.exe from C# and having no luck. I'm constructing a ProcessStartInfo object and have set process.StartInfo.RedirectStandardOutput = true, but when I try to read process.StandardOutput I get the following error:
Message=StandardOut has not been redirected or the process hasn't started yet.
I even tried just piping the output of my command to output.txt, and while the file gets created it's empty.
The process completes but doesn't really execute the intended file, so I'm trying to capture StandardOutput to see what's going on. Just for background purposes I'm trying to run a PVCS get command to get a file out of PVCS.
Here's a snippet of my code:
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo();
process.StartInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.WorkingDirectory = "c:\\gitmover";
startInfo.FileName = "C:\\Program Files (x86)\\Serena\\vm\\win32\\bin\\pcli.exe";
Console.WriteLine("Password:?");
string password = Console.ReadLine();
for (int i = 0; i < revisionsArray.Count(); i++)
{
string fileName = "/" + file.Key.Substring(file.Key.IndexOf("Customers")).Replace('\\','/');
startInfo.Arguments = "get -r" + revisionsArray[i] + " -id\"beng:" + password + "\" -prM:\\Engineering\\SOUP -o -ac:/gitmover -bp'/Customers' -z " + fileName + "> output.txt";
process.StartInfo = startInfo;
process.Start();
string strOutput = process.StandardOutput.ReadToEnd();
//Wait for process to finish
process.WaitForExit();
}