Heyas
A variable within a loop doesnt get updated - eventhough the 'inputfile' changes.
I have a tempfile ($TMP.playstatus), which contains this data:
Where constantly a new line is appended.
I have this semi working:
Deleted stuff (previous tries):
Regardless of what i try, the
$CUR -value is read properly only the first time - so it seems to me, but afterwards it remains the same/doesnt change...
As in, beeing spamed with:
OR, almost the same:
To my understanding the variable
$CUR should be updated just before its
echo 'd within each loop.
Any advice/ideas please?
Thank you in advance
---------- Post updated at 11:14 ---------- Previous update was at 10:38 ----------
Maybe this different output helps:
Outputs as:
Since the background job is told to redirect its output to
$STATUS i thought after the cleaning the new lines would still be added.
Even when i DELETE the tempfile ($STATUS), it doesnt read a value while the files doesnt exist, and after... it jumps back to the first value (0.01), as if its 0.01 was even on the lowest line...
:confused::eek:
A variable within a loop doesnt get updated - eventhough the 'inputfile' changes.
I have a tempfile ($TMP.playstatus), which contains this data:
Code:
0.11 M-A: 0.000 fd= 0 aq= 4KB vq= 0KB sq= 0B f=0/0
0.14 M-A: 0.000 fd= 0 aq= 4KB vq= 0KB sq= 0B f=0/0
0.16 M-A: 0.000 fd= 0 aq= 4KB vq= 0KB sq= 0B f=0/0
0.19 M-A: 0.000 fd= 0 aq= 4KB vq= 0KB sq= 0B f=0/0
0.23 M-A: 0.000 fd= 0 aq= 4KB vq= 0KB sq= 0B f=0/0
0.26 M-A: 0.000 fd= 0 aq= 4KB vq= 0KB sq= 0B f=0/0
0.28 M-A: 0.000 fd= 0 aq= 4KB vq= 0KB sq= 0B f=0/0
0.31 M-A: 0.000 fd= 0 aq= 4KB vq= 0KB sq= 0B f=0/0
0.35 M-A: 0.000 fd= 0 aq= 4KB vq= 0KB sq= 0B f=0/0
I have this semi working:
Code:
$SHELL "$TMP" &
PID=$!
sleep 1.4
while ps $PID > /dev/zero
do CUR=$(tail -n1 $TMP.playstatus|awk '{print $1}')
# Deleted stuff
echo tui-progress -bm "$PTS" -c "$CUR" "$CUR/$PT"
done
return
Code:
#CUR=$($AWK '/M-A:/ {print $1}' $TMP.playstatus )
#M-A:
#echo "--> $CUR <--"
#tail -n1 $TMP.playstatus
#CUR=${CUR/\/*}
#echo $CUR
#$AWK '/M\-A:/ BEGINN {print $1}' $TMP.playstatus
# [ -z "$CUR" ] && \
# pkill ffplay && \
# tui-printf -S 1 "Cant read current playtime from $video, aborting..." && \
# tail -n1 $TMP.playstatus && \
# echo "---" && cat "$TMP" && \
# exit 1
#exit
#sh -x \
As in, beeing spamed with:
Code:
tui-progress -bm 3526 -c 0.04 0.04 /58:46
tui-progress -bm 3526 -c 0.04 0.04 /58:46
tui-progress -bm 3526 -c 0.04 0.04 /58:46
Code:
tui-progress -bm 3526 -c 0.01 0.01/58:46
tui-progress -bm 3526 -c 0.01 0.01/58:46
tui-progress -bm 3526 -c 0.01 0.01/58:46
Any advice/ideas please?
Thank you in advance
---------- Post updated at 11:14 ---------- Previous update was at 10:38 ----------
Maybe this different output helps:
Code:
sleep 0.4
while ps $PID > /dev/zero
do CUR=$(tail -n1 "$STATUS"|$AWK '{print $1}')
>"$STATUS"
echo tui-progress -bm "$PTS" -c "$CUR" "$CUR/$PT"
sleep 0.7
done
Code:
tui-progress -bm 3526 -c 0.01 0.01/58:46
tui-progress -bm 3526 -c /58:46
tui-progress -bm 3526 -c /58:46
Even when i DELETE the tempfile ($STATUS), it doesnt read a value while the files doesnt exist, and after... it jumps back to the first value (0.01), as if its 0.01 was even on the lowest line...
:confused::eek: