0

Hi i want to read a Process.StandardOutput.Readline() until the process asks for input

Pseudo code :

while(cmd doesn't asks for input) 
{
    Console.WriteLine(p.StandardOutput.ReadLine())
}

i've already tried

while(!p.StandardOutput.EndOfStream) 
{
    Console.WriteLine(p.StandardOutput.ReadLine())
}

but it makes an infinite loop because the process asks for input

thanks in advance :)

Mong Zhu
  • 23,309
  • 10
  • 44
  • 76
Dacow
  • 11
  • 1
  • If the process outputs: *Please enter name:* (or what ever it puts on the outputstream) you'll find that text when you do a ReadLine(). When you do, act accordingly. There is no other magic to help you out. – rene Jul 06 '20 at 08:36
  • You seem to be looking for something that will never end anyway. Inputs are part of the stream, the `p.StandardOutput.ReadLine()` is waiting for something to be written to the stream so it can read it. – string.Empty Jul 06 '20 at 08:39
  • Do know that you probably need to handle the datareceived events, instead of looping: https://stackoverflow.com/questions/15032643/get-values-from-process-standardoutput/15032982#15032982 – rene Jul 06 '20 at 08:48
  • Thanks a lot Rene you solved my problem ;) – Dacow Jul 06 '20 at 09:32

0 Answers0