0

I am using netcat to run a file over a network like so

nc -lvnp 1111 -e file

on the client machine, the connection is empty and I only get an output after I enter an input.

How to show the output of the program before asking for input, the program is a c code

printf("Enter name");
scanf("%s", user); 

the program shows Enter name only after I enter something to user

sam
  • 1
  • Buffering, probably. What happens when you flush stdout with `fflush(stdout);` right after the `printf` call? – thrig Aug 23 '22 at 20:39
  • In the title there is "why?", in the body there is "how to". Regarding the latter: [this answer](https://unix.stackexchange.com/a/549505/108618) where it states "Without `pty` it's normal to get `Input a number:` only after you actually provided input blindly". I'm not sure what you can do with `nc` though. – Kamil Maciorowski Aug 23 '22 at 20:53

0 Answers0