Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 08-23-2012, 07:08 AM   #1
LQ Newbie
Registered: Jul 2012
Posts: 10

Rep: Reputation: Disabled
dialog command buffering problem in pipe

I am trying to pipe percentage values into pipe by the following methods:

rsync -a --progress ~/Desktop/test.tar.gz ~/Downloads | 
 	unbuffer -p grep -o "[0-9]*%" | 
 	unbuffer -p cut -f1 -d '%'|
        dialog --title "Test" --gauge "Copying file. " 6 100
If you try to copy a file from a DVD, the dialog screen is reset every time and the screen just shows 0%.

I am trying an alternative:
dialog --title "Test" --gauge "Copying file." 6 100 <<< "$(
 	rsync -a --progress ~/Desktop/version-000.tar.gz ~/Downloads |       unbuffer -p grep -o "[0-9]*%" | 
 	unbuffer -p cut -f1 -d '%'  
The alternative method is buffering the data and I am not able to display the data immediately. Are there alternatives?
Old 08-23-2012, 07:25 AM   #2
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 635

Rep: Reputation: 186Reputation: 186
I came across a similar problem when trying to put an mencoder/ffmpeg video conversion progress inside a dialog gauge widget.
You can try it this way (warning: the following script needs polishing):
rsync  -aP FILE  DEST | while read -d $'\r' INFO
	#Retrieve progress %
	progress=$(echo "$INFO" | awk '{print $2}')
	#Remove trail %
	#Pass the progress % to dialog
	echo $progress | dialog --title "Insert a title here" --gauge "Insert some useful text here" 6 100
You'll extract a wrong progress indicator on the first lines of rsync output, but that can be mitigated with appropriate checks on the progress variable.
1 members found this post helpful.


dialog, rsync, shell script

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
pipe buffering/blocked write caching question genmaicha Programming 2 04-04-2010 05:51 PM
Dialog GAUGE - How to display progress of compile? broken pipe problem? laikos Programming 3 07-03-2004 07:08 PM
Streams and buffering problem MadCactus Programming 2 02-17-2004 01:32 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:06 PM.

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