LinuxQuestions.org
Review your favorite Linux distribution.
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
 
Thread Tools
Old 12-29-2004, 08:27 PM   #1
zackarya
Member
 
Registered: Jul 2003
Distribution: OpenSuse 10, Debian
Posts: 152
Thanked: 0
Need help with dialog(Xdialog) --gauge option


[Log in to get rid of this advertisement]
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.
zackarya is offline     Reply With Quote
Old 12-29-2004, 11:38 PM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 3,697
Thanked: 103
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.
gnashley is offline     Reply With Quote
Old 01-03-2005, 07:12 PM   #3
zackarya
Member
 
Registered: Jul 2003
Distribution: OpenSuse 10, Debian
Posts: 152
Thanked: 0

Original Poster
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.
zackarya is offline     Reply With Quote
Old 01-04-2005, 07:11 AM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,498
Thanked: 44
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..
Hko is offline     Reply With Quote
Old 01-11-2005, 03:15 PM   #5
zackarya
Member
 
Registered: Jul 2003
Distribution: OpenSuse 10, Debian
Posts: 152
Thanked: 0

Original Poster
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.
zackarya is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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:50 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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration