I need a server that should receive data streams, store them in files and send further. Each connection should create a file with corresponding timestamp in file name, then write to it.

My solution:

nc -l -k -p 4000 | date +"%Y-%m-%d_%H_%M_%S" | xargs -I {} tee file_{}.dat | nc 4001

It worked before decision about timestamps and separate files was made, but now I'm stuck on creation of files. netcat complains: getaddrinfo: name or service not known

  • You're outputing your first command (nc) to a file named date. Please, make your example more clear (hopefully a single script or "two terminal windows"). – Felipe Lema Jul 6 '15 at 12:07
  • Indeed, my mistake. Corrected. – ZuOverture Jul 9 '15 at 0:02

You can't. EOF is not piped to the next command when a connection ends. See this other answer

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.