Using the following command, the “hello” message can be sent 1000 times without manually typing it:
for i in {1..1000}; do echo hello | nc localhost:8080; done
The command above creates a for
loop which sends the “hello” message 1000 times. The for
loop is used to iterate over a range of numbers specified between {1..1000}
and send the “hello” message to the server using the echo
command and the nc
command.
The nc
command, also known as Netcat, is used to connect to a TCP server. In this case, the server is listening on port 8080
of the local host.