I have a script which works for buffering (in the code below I have it set for 5000 milliseconds) except that I do not know how to call the needed python script with an indefinite number of arguments. How would this be done?
EDIT:
I have updated the if
logic in the while
loop to reflect the "hack" which works with a for
loop of the arguments, but I know there's a one-line solution to this.
NOTE: I suppose that I could loop through the $lines
, create a string and eval() but that seems ugly
NOTE 2: I am new to bash; comments on overall coding are appreciated after the primary question are answered.
#!/bin/bash
sent=0
interval=5000
lines=()
i=0;
while read line; do
lines[$i]=$line
((i++))
point=$(($(date +%s%N)/1000000));
if [ $((point-sent)) -gt $interval ]
then
cmd="php LineProcessor.py";
for arg in "${lines[@]}"
do
cmd="$cmd \"$arg\""
done
eval $cmd
sent=$point
# -- reset lines array --
i=0
lines=()
fi
done