LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Dialog gauge question (https://www.linuxquestions.org/questions/linux-newbie-8/dialog-gauge-question-4175451003/)

bryanh 02-20-2013 03:36 PM

Dialog gauge question
 
I already wrote a script using barcode, ps2pdf, pdftk and of course bash to create a pdf document for each record in a database file.

so basically the script goes [ short jest here ]

for idnum in `cat database`
do
barcode -b $idnum -o $idnum.ps # barcode program takes value makes
# ps file of value [scannable barcode]

ps2pdf $idnum.ps $idnum.pdf # converts ps to pdf file

pdftk template.pdf background $idnum.pdf cat output vendor_$idnum.pdf

# the pdftk background takes a template and I merge my barcode pdf to
# it so I can get a company logo, etc...

done
pdftk vendor*.pdf cat output master_vendor.pdf #make master pdf of
# all database records

rm -rf vendor*.pdf

what I would like to do is show a dialog gauge after each record in database is converted to vendor_$idnum.pdf

I am new at programming and got my gauge to work by saying something like last_record=`wc -l < database` and count=1 and made a loop function to progress thru but dumb me only gets dialog gauge to run its own loop and not progress thru the steps above I want to complete

Can anyone help? Also point me to where I could learn more about dialog-seen examples but for me to learn I need alot of examples-
more than one example program to sink into my brain...

Habitual 02-20-2013 08:54 PM

Quote:

Originally Posted by bryanh (Post 4896239)
what I would like to do is show a dialog gauge after each record in database is converted to vendor_$idnum.pdf
...
Can anyone help? Also point me to where I could learn more about dialog-seen examples but for me to learn I need alot of examples-
more than one example program to sink into my brain...

If you know how programming control works, this real example may help.

It uses Yad (yet another dialog)
YAD is a program that will display GTK+ dialogs (GUI'fied dialogs)

Code:

#!/bin/bash
################################################################
# Name:              AWS SnapsCount
# Version:            1310054340
# Author:            jj_of_c9
# Date:                Thu Jul 07, 2011
# Requirements:        yad,ec2-api-tools
# Description:        Retrieves AWS Snapshots and counts them.
################################################################
export EC2_HOME=/edit/me
#Local date/time stamp
var1=`date`

yad --image=/home/jj/Documents/cirrhus9/Legal/cirrhus9_logo_blue.png --no-buttons --undecorated --skip-taskbar --timeout=2
function do_work()
{
var3=`echo -n "FTB Snapshots="$(/home/jj/Bin/ec2/bin/ec2-describe-snapshots -K /home/jj/.ssh/domain.com/pem/pk-32CHARACTERS.pem -C /home/jj/.ssh/domain.com/pem/cert-32CHARACTERS.pem --region us-west-1 | sort -r -k 5 | wc -l)`
}

touch /tmp/$$
( ( echo 1 ; while [ -f /tmp/$$ ] ; do sleep 1 ; done ; echo 100 ) | yad --progress --pulsate --auto-close --text="Counting Snapshots..." --width=150 --title="" --undecorated --no-buttons) & do_work
rm /tmp/$$

#output
echo -e "$var1\n$var3"| yad --text-info --show-uri --width=300 --height=265 --center --name="EC2 Snapshots" --window-icon="/home/jj/Documents/favicon.ico" --button=Done

Basically, write a /tmp/$$ and then process the work with do_work() function.
When that's done, remove /tmp/$$


"5) Building a Gauge"
http://mywiki.wooledge.org/BashFAQ/044
http://mywiki.wooledge.org/BashFAQ/040

should get you started, I hope.

Good luck!

subscribed with interest...

JJ


All times are GMT -5. The time now is 07:02 PM.