LinuxQuestions.org
Visit Jeremy's Blog.
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 08-23-2012, 07:08 AM   #1
yamanoorsai
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:

Code:
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:
Code:
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
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
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):
Code:
rsync  -aP FILE  DEST | while read -d $'\r' INFO
do
	#Retrieve progress %
	progress=$(echo "$INFO" | awk '{print $2}')
	#Remove trail %
	progress=${progress%\%*}
	#Pass the progress % to dialog
	echo $progress | dialog --title "Insert a title here" --gauge "Insert some useful text here" 6 100
done
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.
  


Reply

Tags
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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:54 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration