[ artriba @ 27.04.2008. 18:50 ] @
Pokušavam pokrenit jedan konzolni program iz svog programa, ali mi ne ide. Kad pokrenem program "ručno" iz komand prompta sa argumentima sve radi. Kad to napravim iz svog programa ne radi. Jednostavno kad program dođe do linije s = reader.ReadToEnd (); jednostavno iskoči Konzolni program i karet počme žmigat i tako stoji. A s bi trebao čitati standardni izlaz tog programa i kasnije ga ispisati na konzolu mog programa. Code: using System; using System.IO; using System.Diagnostics; class Program { static void Main ( string [] args ) { Process p = new Process (); String s; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = "gnugo.exe"; p.StartInfo.Arguments = "--mode gtp"; p.Start (); StreamReader reader = p.StandardOutput; StreamWriter writer = p.StandardInput; writer.AutoFlush = true; writer.Write ( "1 boardsize 7" ); s = reader.ReadToEnd (); Console.WriteLine ( s ); writer.Write ( "exit" ); } } Evo recimo kako piše u dokumentacij tog programa. Kad ga pokrenem iz cmd.exe sa argumentima on mi nakon komande "1 boardsize 7" ispiše "=1" Code: To start GNU Go in GTP mode, simply invoke it with the option `--mode gtp'. You will not get a prompt or any other output to start with but GNU Go is silently waiting for GTP commands. A sample GTP session may look as follows: virihaure 462% ./gnugo --mode gtp 1 boardsize 7 =1 2 clear_board =2 3 play black D5 =3 4 genmove white =4 C3 5 play black C3 ?5 illegal move 6 play black E3 =6 7 showboard =7 A B C D E F G 7 . . . . . . . 7 6 . . . . . . . 6 5 . . + X + . . 5 4 . . . + . . . 4 3 . . O . X . . 3 2 . . . . . . . 2 WHITE (O) has captured 0 stones 1 . . . . . . . 1 BLACK (X) has captured 0 stones A B C D E F G 8 quit =8 |