LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-03-2004, 04:52 AM   #1
laikos
Member
 
Registered: Nov 2002
Distribution: Slackware 8.1
Posts: 30

Rep: Reputation: 15
Dialog GAUGE - How to display progress of compile? broken pipe problem?


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
 
Old 07-03-2004, 05:43 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
I'm not if this helps you, but you can split a pipe in 2 by making a filesystem-pipe ("fifo") and use the "tee" program to write to the fifo while also have the same output flow donw the normal pipe line. Somthing like this:

Code:
mkfifo /tmp/my_fifo
$CMD | awk '{ print $1 }' | tee /tmp/my_fifo | xargs -n1 echo "$COMPLETE" &  #note '&': run in background.
cat /tmp/my_fifo | your_progress_bar_program
 
Old 07-03-2004, 10:06 AM   #3
laikos
Member
 
Registered: Nov 2002
Distribution: Slackware 8.1
Posts: 30

Original Poster
Rep: Reputation: 15
Thanks HKo for your reply,
It does help however I found out that there's something wrong with the update
I did this instead
[code]
export COMPLETE=1200
./cvscompile | awk '{ Total +=1; print (Total/ENVIRON["COMPLETE"])*100 }'

1
2
3
4
5
.... (steadily and sequentially
[code]

However, when I pipe in the output to the "dialog" program, I got a long pause then a suddent rush to 100%
Code:
export COMPLETE=1200
./cvscompile | awk '{ Total +=1; print (Total/ENVIRON["COMPLETE"])*100 }' | dialog --gauge "Compiling" 7 70
I'm pretty confused now
 
Old 07-03-2004, 07:08 PM   #4
laikos
Member
 
Registered: Nov 2002
Distribution: Slackware 8.1
Posts: 30

Original Poster
Rep: Reputation: 15
Hi All!
It's working. For some reason when I woke up this morning I tried this
Code:
./cvscompile 2>&1 | awk '{ print (Total+=1)/60.6,"=>",$0}' | dialog --gauge "Compiling..." 7 70
where 60.6 (is 1/10) of the total output line it will produce
I'm heading for a happy breakfast now
Thanks you guys.

Last edited by laikos; 07-03-2004 at 07:09 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with dialog(Xdialog) --gauge option zackarya Programming 7 09-02-2010 03:25 AM
Broken pipe? Nubian Linux - Newbie 2 08-16-2005 08:56 AM
JAVA and TOMCAT problem : Broken Pipe fellsin Linux - Software 1 01-13-2005 01:47 AM
RPM...Broken Pipe Problem.........it's urgent..plz shivas Linux - Newbie 1 12-15-2004 04:38 AM
Broken Pipe Cynthia Blue Linux - Newbie 0 12-30-2002 02:31 PM


All times are GMT -5. The time now is 07:30 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration