Process timer

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

Process timer

#1 Post by jpeps »

Name: "timer"

Adds a process timer to script. Add "timer &" before process, and "kill `pidof timer`" after.

Note: Also helps to add a newline after timer: 'echo -e "\nDone!"'

Code: Select all

#!/bin/sh

#### begin with:  "timer & " 
###  end with:    "kill `pidof timer` " 
 

CYAN='\E[36;40m'

SEC="0"

echo -en $CYAN"\nWorking..............."
while [ "$0" ]; do
  for ((i=0;i<1000001;i++)); do 
  
    SEC="$(( $SEC+1 ))"
 [ ${SEC} -gt 0 -a ${SEC} -lt 11 ] &&  echo -en "$SEC"   
 [ ${SEC} -gt 10 -a ${SEC} -lt 101 ] &&  echo -en "\b$SEC"   
 [ ${SEC} -gt 100 -a ${SEC} -lt 1001 ] &&  echo -en "\b\b$SEC"   
 [ ${SEC} -gt 1000 -a ${SEC} -lt 10001 ] &&  echo -en "\b\b\b$SEC"   
 [ ${SEC} -gt 10000 -a ${SEC} -lt 100001 ]  &&  echo -en "\b\b\b\b$SEC"   
 [ ${SEC} -gt 100000 -a ${SEC} -lt 1000001 ] &&  echo -en "\b\b\b\b\b$SEC"   
    echo -en "\b"
    sleep 1
   done
done

Post Reply