LinuxQuestions.org
Register a domain and help support LQ
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 12-29-2004, 08:27 PM   #1
zackarya
Member
 
Registered: Jul 2003
Distribution: OpenSuse 10, Debian
Posts: 152

Rep: Reputation: 30
Need help with dialog(Xdialog) --gauge option


Hi everyone, I've been searching around but can't really seem to understand how the
--gauge option works for dialog( or Xdialog but I'm currently focusing on just dialog).

What I have is this:

dd if=/dev/urandom of=$fileName bs=1024K count=$fileSize

Where the variables are filled in by the user through dialog. What I want to do is
use gauge to show the file progress while it's creating and more importantly I
would like to understand WHY it works the way it does. I've played around a lot
with different things (using mkfifo, expr) and can get some amount of success but
since I don't understand what's going on I can't get any farther. Thanks.
 
Old 12-29-2004, 11:38 PM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,775

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Only place I've seen this used was in a Knoppix script (knoppix-autoconfig maybe). I tried to get it to work on Slackware without success.
 
Old 01-03-2005, 07:12 PM   #3
zackarya
Member
 
Registered: Jul 2003
Distribution: OpenSuse 10, Debian
Posts: 152

Original Poster
Rep: Reputation: 30
Thanks for the reply. I've looked through the knoppix scripts (The little success I've gotten was by using their code.) The areas I'm looking at are:

gauge(){
rm -f "$TMP.done"
status=0
while [ ! -e "$TMP.done" ]; do echo "$status" ; status="`expr \( 100 - $status \) / 4 + $status`"; sleep 2; done | $DIALOG --title "$TITLE1" --gauge "$1" 8 75 0
}

# Stop status bar
killgauge(){
touch "$TMP.done" ; wait ; rm -f "$TMP.done"
}

So here is what they do.

gauge "somemessage" &
dd if=/dev/zero of=$DEVICE bs=1M count=$AMOUNT || { killgauge; sleep 2; bailout; }

the bailout function deletes some temp files, unmounts drives, etc.

Now, when I try to use this in my script it will start creating the file and the dialog pops up,
everything looks good until it get's to about 90% and it slows way down. I know the file is finished creating but gauge never gets to 100%. I don't know enough about the status="`expr`" line to know why this is happening. Can anyone offer any insight. Thanks for your time.
 
Old 01-04-2005, 07:11 AM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Maybe this bash script helps:
Code:
#!/bin/bash

PIPE="/tmp/pipe_$$"
set -m

mkfifo "$PIPE"
Xdialog --ignore-eof --gauge Aloha 10 30 <"$PIPE" &
sleep 1
for i in `seq 0 20 100` ; do
    echo $i >"$PIPE"
    echo "$i%"
    sleep 1
done

jobs -x kill %%
rm "$PIPE"

Last edited by Hko; 01-04-2005 at 07:12 AM.
 
Old 01-11-2005, 03:15 PM   #5
zackarya
Member
 
Registered: Jul 2003
Distribution: OpenSuse 10, Debian
Posts: 152

Original Poster
Rep: Reputation: 30
Thanks, I think I get it now.

Thanks Hko, I understand it a lot better now. Like I said before I've been trying to get this to work with dd ( or mkfs, etc.) But now it seems that what one really has to do is to simply guess (thus the expr from the knoppix example above) in a way that makes it LOOK like it is keeping track of the current status of the file or whatever. This is a REALLY POOR soultion in my opinion. I have found a few ways that it's possible to know where dd is in the creation process. For instance I found while dd is running I can kill the process and by sending it -USR1 what it does is pause, display how far along it is and continue, sounds like just what I need. The problem though is that this of course stops the file creation for a moment and it seems that the overall overhead is not worth it. Another idea I had would be to have a seperate thread which would just keep doing a du on the file that is being created and compare it to the total filesize it's to create to and use this information to update gauge. Either way it would be more overhead. I havn't seen anyone else who actually checks for the real file progress. It SEEMS that EVERYONE just guesses. So I ask, what is the point of even having a progress bar if the information it displays is not accurate. Maybe I'm missing something here. As a final note I just want to say to everyone here at linuxquestions.org that this forum has become my first stop when looking for information(about Linux). I use to go to google first but I've recently started to realise that google always ends up pointing me back here. So just a big thanks to all of you.
 
Old 08-31-2010, 04:42 PM   #6
bcnx
LQ Newbie
 
Registered: Aug 2010
Posts: 14

Rep: Reputation: 0
Hi,

quite an old thread and not sure if anyone watching anymore, but I'm trying to create a dialog gauge as well to show the progress of dd. Sending USR1 to the PID however outputs the statistics to standard error, making it hard to capture them.

Anyone know how?

thx!

B.
 
Old 09-01-2010, 03:27 AM   #7
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,775

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
I'm attaching a small archive with several examples using guage and progressbar which I created. As the last poster mentioned, most people use them with guessed values for the time it takes to perform a task. The only other way is to rpeatedly check the actual progress of the task -if possible. And doing so will slow down the process considerably.
What I usually wound up doing was using some sort of 'spinner' type thing. I've included some examples of that also. They simply display a changing set of characters which look like expanding stars or similar. If using Xdialog, you could even do something similar with a changing icon display.

The attached file is a tar.bz2 archive -just change the '.txt' to '.bz2' to be able to unpack it.
Attached Files
File Type: txt Xdialog-examples.tar.txt (2.0 KB, 22 views)
 
Old 09-02-2010, 04:25 AM   #8
bcnx
LQ Newbie
 
Registered: Aug 2010
Posts: 14

Rep: Reputation: 0
Gnashley,


thx for your reply and your files. I looked at some, but you don't seem to link the progress of dd to dialog --gauge anywhere, is this right? Is there no way to do this? Because it standard error could be captured, it should be quite easy to calculate how much percent this is of the total file size.

thx again,

Bart
 
  


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 Xdialog justintime32 Linux - Software 1 06-17-2005 03:17 PM
Using Xdialog to su death_au Linux - Newbie 1 05-31-2005 11:41 PM
Xdialog --geometry bendeco13 Linux - General 0 11-06-2004 01:20 AM
Xdialog --progress bendeco13 Linux - General 0 10-27-2004 09:58 PM
Dialog GAUGE - How to display progress of compile? broken pipe problem? laikos Programming 3 07-03-2004 08:08 PM


All times are GMT -5. The time now is 08:20 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration