I've seen a lot of things about redirecting stdout to a TCP socket, but no real example of how to do it in practice, specifically when the output stream generated by the first "command" never ends.
To talk about something concrete, let's take programs like servers that typically output their log endlessly to stdout (well, as long as they run). If you redirect the output to a log file on the disk, then this file is always open (therefore not readable by others?) and grows infinitely, which eventually is going to cause problems.
This might be a nood question, but I don't know what it does or how to do it so.
- How to redirect the output of a command to the internal loop?
- I want to make sure that data is sent EVERY time something is written to stdout, and that the pipe won't wait for the command to end (never happens ideally!). Is that right?
- If 2 is true, is there a buffer system to send chunks of data once it reaches a certain size only?
- Could you give me concrete command line examples to do the above?
Thanks in advance
nc(netcat)? If I understand your question correctly, I think you can accomplish it by doingyes | nc 123.45.56.78 1234whereyesgenerates the output continuously, and thencparameters are the IP address and port as the target. Please refer to the manpage ofnc. – gertvdijk Jun 28 '13 at 09:11yesto terminate to send the data stream, right? – Jonathan H Jun 28 '13 at 09:15unbuffer,stdbuf, etc. However, they are not needed if you use nc. – ignis Jun 28 '13 at 09:33