Reputation: 1
So this is my output...
00-
01- Wallet : 123456789123465789
02-
03- --------------------
04- Server Stats Update:
05- --------------------
06- Work Units : 0 (cancelled:0 | completed:0)
07- Average Complete Time : 0
08-
09- -------------
10- Stats Update:
11- -------------
12- Work Units : 0 (ondemand:0 | precache:0 | paid:0)
13- Prize Pool : 0% - Earned : 0
14-
I need the lines 06,07,12 and 13 to keep refreshing... the only method I found so far is by making a loop and clearing the output every two seconds...
Also I found that printf \033[A
could be useful but I couldn't figure how to implement it here...
My code...
while true: do
echo -e "\n Wallet : ${Address} \n"
echo --------------------
echo Server Stats Update:
echo --------------------
echo -e " Work Units : ${ServerOverallWU} (cancelled:${Cancelled} | completed:${Completed}) "
echo -e " Average Complete Time : ${AvgCompTime} "
echo
echo -------------
echo Stats Update:
echo -------------
echo -e " Work Units : ${SaveOverallWU} (ondemand:${SaveOnDemand} | precache:${SavePreCache} | paid:${SavePaidWU}) "
echo -en " Prize Pool : ${SavePrizePool}% - Earned : ${SaveEarned} "
done
Ps: Fixed... just put the clear on the right stop and now it runs smooth as butter
Upvotes: 0
Views: 373
Reputation: 7277
I've got a function for that
XY () { printf "\e[$2;${1}H$3"; }
Usage
XY 1 13 "Hello World!"
It'll print 'Hello World!' on column 1 of line 13.
Comparing this with tput
for i in {1..100}; {
tput cup $1 $2; printf "Hello World!"
}
real 0m0,130s
user 0m0,079s
sys 0m0,055s
for i in {1..100}; {
XY $1 2 "Hello World!"
}
real 0m0,002s
user 0m0,002s
sys 0m0,000s
Upvotes: 0
Reputation: 189357
If you want complete control over your screen, you can probably clear
it at the beginning of the script and then use direct cursor addressing to only repaint parts of the screen (i.e. move the cursor to position 1,13; repaint that line to replace it; then move to line 15 and repaint that) but this will be rather ugly and painful in pure Bash. Perhaps you should use a curses
wrapper like whiptail
to shield you from the details. Maybe see also https://unix.stackexchange.com/questions/155417/a-set-of-libraries-like-ncurses-in-a-shell-script
Upvotes: 1