Hi All,
I have been working on script to compile the alsa code on my machine. I wish to create a script to wrap up the installation such that it will display progress bar using the dialog --gauge option instead of just the output.
I managed to get the dialog --gauge working using the follow script
Code:
##############################################################################
# display progress
##############################################################################
display_progress(){
DIALOG=dialog
echo "Display Progress"
CMD="$1"
COMPLETE="$2"
PROGRESS_TITLE="$3"
HELP_TXT="$4"
$CMD | awk '{ print $1 }' | xargs -n1 echo "$COMPLETE" | awk '{ TotalLine+=1; print ((TotalLine/$1)*100); if (TotalLine > $1) { TotalLine=$1 } }' | $DIALOG --backtitle "$INSTALLER_TITLE" --title "$PROGRESS_TITLE" --gauge "$HELP_TXT" `expr $SCREEN_HEIGHT / 5` $SCREEN_WIDTH
} #end display progress
I will issue a command like
Code:
display_progress "tar -jxvf alsa-driver-$ALSA_VERSION.tar.bz2" "1200" "Uncompressing ALSA DRIVER source" "Uncompressing ALSA DRIVER Source ; alsa-$ALSA_VERSION into your hard drive"
This command create a nice progress bar while the file is being uncompressed. :-)
However
When I try to use the command with cvscompile or any other script I can't get the output from that script go all the way through the pipe. It will stop at the second pipe.
That's mean
Code:
$CMD | awk '{ print $1 }'
Will produce output but
Code:
$CMD | awk '{ print $1 }' | xargs -n1 echo "$COMPLETE"
Produces nothing.
I hope anyone could explain and help with this program because it's really confusing me
Thanks in advance