Progress indicator script

Can anybody suggest you a good script to show progress of a process.

I figured it out some thing like this. But cursor goes to the end of the line and after every loop it goes to the next line.

while true ; do
for i in \| \/ \- \\ \| \/ \- \\
do
echo "\b\b$i \c"
sleep 1
done
done

The carriage return character (\r, ASCII 13) returns the cursor to beginning of line without advancing to the next line.

If you have printf that might be slightly less unwieldy than echo.

Try echo -n.

Regards

One more way of doing this..

#!/bin/sh

percent=0
(
while test $percent != 101
do
echo $percent
echo "XXX"
echo "This is how the gauge appears"
echo "XXX"
echo "See how the message changes"
echo "XXX"
percent=`expr $percent + 1`
sleep 1
done
) |
dialog --title "Main Window!" --gauge "This is how a gauge appears on the command line" 10 60 0

It seems This is for Linux. My machine is UX

You can get dialog for HP-UX too. http://hpux.connect.org.uk/hppd/hpux/Shells/dialog-1.1/

(Funny they should use Debian as their upstream, though. According to the corresponding Debian packages, the original upstream is ftp://invisible-island.net/dialog/. I found a home page at http://invisible-island.net/dialog/dialog.html.\)

Thank you era!! let me try

Thank you nua7 and era. I could recall my favourite dialog boxes in my UX Box now...

The alarm disciple function of ksh93 can be used to output a progress bar as the following simple example shows:

#!/usr/bin/ksh93

alarm -r progressbar +1

progressbar.alarm()
{
   tput cup 2 10
   (( ++progressbar.pvalue > 50 )) && {
      tput cup 2 10; tput el
      progressbar.pvalue=0
   }
   printf "Progress: %s" "${progressbar.pstr:1:${progressbar.pvalue}}"
}

progressbar.pvalue=0
progressbar.pstr="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

tput clear
read dummy        # dummy wait - press return to exit
tput clear

exit 0