I am facing problem while sending reading python command in CMD through C#. Actually I have to open file in cmd and then pass several commands like reading db and passing other constraints to my python file from GUI which is devloped in C#. Here is my code
I have tried with cmd.exe and also with FULL_PATH_To_PYTHON/Python.exe but I am unable to open file and then send command like reading db.
In cmd i do it by opening file ike python -i saddle.py but here this command is not working like I tried proc.StandardInput.WriteLine("python -i saddle.py"); but system crashes.
I even found IronPython for this solution but don't know that that will solve my problem as I don't know about how to read its output in textbox.
private void button5_Click(object sender, EventArgs e)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.WorkingDirectory = @"E:\..\saddle";
psi.FileName = "cmd.exe";
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardError = false;
var proc = Process.Start(psi);
proc.StandardInput.WriteLine("saddle.py");
// proc.StandardInput.WriteLine("open_db(['db/generic.xml', 'db/generic-server.xml','db/intel-xeon-2600.xml', 'db/intel-xeon-phi.xml','db/memory.xml', 'db/network.xml', 'db/hdd.xml','db/ssd.xml'])");
proc.StandardInput.WriteLine("exit");
string s = proc.StandardOutput.ReadToEnd();
Output1.Text = s;
}