Artificial intelligent assistant

How to use nc to send message consecutively per second I'm learning the Apache Flink. Here is the Hello World of Flink: < This example is a program, which counts the words in every 5 seconds. If we want to run this sample, we need to do the following steps: * Execute `nc -l 9000` on one terminal (A); * Execute `./bin/flink run examples/streaming/SocketWindowWordCount.jar --port 9000` on another terminal (B); * Go to the terminal A and type some words. If we `Ctrl-c` on the terminal A, this sample will be terminated. I want to know if it is possible to type the words programmatically at the terminal A. For example, I want to type the word `lol` per second at the terminal A, what should I do? The code below won't work. #!/bin/bash while true; do echo 'lol' | nc -l 9000 sleep 1 done Of course, I may try to modify the `SocketWindowWordCount.java` to do so but for now, for some reason, I can not change the java code.

Pipe the whole loop into `nc`:


while true; do
echo 'lol'
sleep 1
done | nc -l 9000


This will start a single instance of `nc`, listening for connections on port 9000, and send “lol” once per second to it.

Note that “lol”s will accumulate until the connection is opened, so you might see a number of “lol”s send immediately on connection. You could add a delay at the start:


(sleep 5
while true; do
echo 'lol'
sleep 1
done) | nc -l 9000

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 3188f58eb052893a523240c4be1ec5f4