2

I'm trying to start a 3rd party command line program using System.Diagnostics ,the program take an argument and send an output and then take some more arguments .... . My problem is how to check if the process is waiting for input so i can pass it via Process.StandardInput

Process myProcess = new Process (){
           StartInfo = new ProcessStartInfo("/home/medo/Desktop/c/tst"){
              RedirectStandardInput = true,
              RedirectStandardOutput = true,
              UseShellExecute = false,
              CreateNoWindow = true,
              WindowStyle = ProcessWindowStyle.Hidden
           }
        };

        myProcess.Start ();


        string output = myProcess.StandardOutput.ReadLine ();

        Console.WriteLine ("output" + output);
        myProcess.StandardInput.WriteLine("argument") ;
        output = myProcess.StandardOutput.ReadLine ();

        Console.WriteLine ("output" + output);

        myProcess.WaitForExit ();
        myProcess.Close ();

if it's not possible in c# please tell me if it's possible in an other language

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
unfamous
  • 611
  • 1
  • 5
  • 14

0 Answers0