2 # Desc: Writes stdin to disk every 5 seconds
3 yell
() { echo "$0: $*" >&2; } #o Yell, Die, Try Three-Fingered Claw technique
4 die
() { yell
"$*"; exit 111; } #o Ref/Attrib: https://stackoverflow.com/a/25515370
5 try
() { "$@" || die
"cannot $*"; } #o
6 declare -a buffer
# Initialize buffer array
10 printf "%s\n" "${buffer[@]}" |
cat |
cat |
cat >> /dev
/shm
/$
(date +%s
)..bkFreqWrite-output1.txt
;
11 printf "%s\n" "${buffer[@]}" |
cat |
cat |
cat >> /dev
/shm
/$
(date +%s
)..bkFreqWrite-output2.txt
;
12 printf "%s\n" "${buffer[@]}" |
cat |
cat |
cat >> /dev
/shm
/$
(date +%s
)..bkFreqWrite-output3.txt
;
16 # Run until script TTL seconds pass
17 while [[ $SECONDS -lt "scriptTTL" ]]; do
18 bufferTOD
="$((SECONDS + $bufferTTL))";
20 # Consume stdin to fill buffer until buffer time-of-death (TOD) arrives
21 while read -r line
&& [[ $SECONDS -lt "$bufferTOD" ]]; do
22 # Append line to buffer array
24 echo "DEBUG:Processing line:$lineCount";
25 echo "DEBUG:Current line :$line";
26 echo "DEBUG:buf elem count :${#buffer[@]}";
29 # Export buffer to asynchronous processing.
31 unset buffer
; # Clear buffer array for next bufferRound
32 # Increment buffer round
36 # Author: Steven Baltakatei Sandoval