improved script parametrization

This commit is contained in:
sesteves 2018-10-02 18:27:48 +01:00
parent d9413269f2
commit 8e542d5187

View File

@ -1,5 +1,19 @@
#/bin/bash
while true
do
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <top.csv)\r\nAccess-Control-Allow-Origin: *\r\n\r"; cat top.csv; } | nc -v -l -p 4870
# last stats file to read from
FILENAME=$(ls stats-* | tail -n 1)
# number of lines to read
N=100
# time to sleep in milliseconds
SLEEP=100
# chunk filename
CHUNK_FILENAME="log-provider-chunk.csv"
header=$(head -n 1 $FILENAME)
while true; do
paste <(echo $header) <(tail -n +2 $FILENAME | tail -n $N) --d '' > $CHUNK_FILENAME
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c $CHUNK_FILENAME)\r\nAccess-Control-Allow-Origin: *\r\n\r"; cat $CHUNK_FILENAME; } | nc -v -l -p 4870
sleep ${SLEEP}e-3
done