<div dir="ltr">Hi,<div><br></div><div>I am using an port to communicate with an external program, I would like to fetch each output from the external problem.</div><div>But I have problem to fetch the output when the external problem runs into waiting input," scanf " for example.</div><div><br></div><div>Here is an example to communicate with a simple C program.</div><div><br></div><div>I need to fetch the prompt line("Please input you name") from Port in order to interact with C code,  but with "scanf" added in C code, I couldn't fetch it from Port.</div><div>Does anyone know why is that ?  Any advice and suggestions will be greatly appreciated.</div><h3 class="gmail-r" style="font-size:18px;font-weight:normal;margin:0px;padding-top:0px;padding-right:0px;padding-left:0px;line-height:1.2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap"><br></h3><div><br></div><div>Erlang code:</div><div><br></div><div><div>read() -></div><div>  Port = open_port({spawn, "/home/erlang/test/a.out"}, [binary, {line, 255}]), %binary,{line, 255}</div><div>  io:format("Port: ~p~n",[Port]),</div><div>  do_read(Port).</div><div><br></div><div>do_read(Port) -></div><div>  receive</div><div>    {Port,{data,Data}} -></div><div>        io:format("Data: ~p~n",[Data]);</div><div>    Any -></div><div>      io:format("No match fifo_client:do_read/1, ~p~n",[Any])</div><div>  end,</div><div>  do_read(Port).</div></div><div><br></div><div>C code:</div><div><br></div><div><div>int main()</div><div>{</div><div><br></div><div>  char str[10];</div><div><br></div><div>  printf("Please input you name:");  //Prompt line</div><div><br></div><div>  scanf ("%9s",str);  // with this line, port can not read the output from this program.</div><div><br></div><div>  return 1;</div><div>}</div></div><div><br></div><div><br></div><div>Br,</div><div>Alex</div></div>