If you are using dialog, the best examples are available from the Xdialog program which uses nearly exactly the same syntax. There are also good examples of using dialog from any of the Slackware utilities or installer.
Here's an example from the Xdialog program for using the gauge widget. You should be able to use it with dialog by just changing the Xdialog to dialog:
echo "10" ; sleep 1
echo "XXX" ; echo "The new" ; echo "\\n" ; echo "message"; echo "XXX"
echo "20" ; sleep 1
echo "50" ; sleep 1
echo "75" ; sleep 1
echo "100" ; sleep 1
$DIALOG --title "GAUGE" --gauge "Hi, this is a gauge widget" 8 30
if [ "$?" = 255 ] ; then
echo "Box closed !"
Hopefully, the exampleso of shell-only progress bars from the thread will help you to find a way to measure and pace the progress of the process. My example of using a while loop gives a chance to check the amount of work completed, or when you reach 100 percent in the above example just reset to 10 and let the gauge run that way until finished.
As I said, finding a way to estimate the time needed to do the job and scaling that to percentages is really the hard part -you must take into account differing screen or terminal widths and differing process speeds(what takes 30 seconds on your machine might take a minute on mine...)
Notice that first part of this example is where the percentage gets set and then it is piped into dialog itself.
Here's another example from Xdialog which uses the progress bar:
# Formats a 1440Kb DOS floppy disk.
TITLE="HD floppy DOS format"
# Change the following variable to suit your system:
# This changes depending on your language...
fdformat -n $DEVICE | \
Xdialog --title "$TITLE" --no-close \
--progress "Please wait while low-level formatting...\n\n" 0 0 \
( mkdosfs $DEVICE 2>/dev/null ; echo "XXXX" ) |
Xdialog --title "$TITLE" --no-close --no-buttons \
--infobox "Making the DOS filesystem..." 0 0 0
Xdialog --title "$TITLE" --msgbox "All done !" 0 0
Note that for the progress bar to work, it needs input which prints a character at intervals -like programs which print out dots until finished, so you have to include some code which will generate these characters, if the program you are tracking does not do so.