My main objective is to Run some commands in cmd using C# code and get the final response as output. This is my code:
processStartInfo = new ProcessStartInfo("cmd.exe",
""/c ssh kovair@192.168.12.232 \"cd git_home && git log --pretty=format:\"%H \"
--after=\"2021-05-20T11:08:00.000000Z\"
--until=\"2021-06-17T23:51:01.000000Z\"\"");
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processStartInfo.CreateNoWindow = true;
processStartInfo.WorkingDirectory = @"C:\Users\xyz\.ssh";
// initialising process and executing it.
process = new Process();
process.StartInfo = processStartInfo;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.UseShellExecute = false;
process.Start();
//reading the output
string response = process.StandardOutput.ReadToEnd();
string error = (string)(process.StandardError.ReadToEnd());
Here basically I am executing
ssh kovair@192.168.12.232 "cd git_home && git log --pretty=format:"%H " --after="2021-05-20T11:08:00.000000Z" --until="2021-06-17T23:51:01.000000Z""
in path
C:\Users\xyz.ssh
Which should get me the Commit Ids from the git server. but here I am getting empty response and in error I am getting
'ssh' is not recognized as an internal or external command, operable program or batch file.
If I manually execute the command it returns me the desired data but when executing it through C# code I am getting this error can anyone help to fix this error