I'm writing a bash script that constantly read a folder in a loop to send data to a server at a defined time interval. I'm using netcat as the tool to connect to the server and send the data. My pseudo code would look like:
while true do read_folder() process_data() > result.txt cat result.txt > netcat ip port wait 10 sec done
My only problem is that in the scenario the client connects and disconnects the TCP/IP connection to the server every time. I would prefer to establish the connection at the start of the script and close it at the end.
Is there any way this could be done with command line tools in a bash script?