conditional confusion


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting conditional confusion
# 1  
Old 07-06-2011
conditional confusion

Hell Unix.com Community:

I am working on a personal project using yad v0.12.4 (zenity fork) and have hit a wall on how to show a progress bar while my function is processing.

I have been all over the ABS Guide, googled 21 Linux-specific sites that I revere. I even asked on the yad-common google group, but I remain stumped. If you don't know yad, think zenity on steroids. Smilie
The author suggested "while pkill -0 ec2-describe-snapshots ; do sleep 0.5; echo "qqq" done | yad --progress --pulsate" but I failed to get it working.

The script has 3 variables. 2 of which are in the function and those 2 go out and grab AWS snapshots and gets the count for each client.

Everything works until I try to implement a "--progress" meter while the function is running.

I want a progress meter to be displayed during the ~11 seconds it takes to execute the function. I have been partially successful at times, but my chop and hack method is driving me Smilie

My code can be seen at SUSE Paste

Thank you for your time.
# 2  
Old 07-06-2011
I can't find a manual page for yad, but I see that you're feeding it data into standard input. Animated things like progress bars may not work if the process is talking to anything but a terminal, and a pipe's not a terminal; is there a way to give it data as commandline parameters instead?
# 3  
Old 07-06-2011
Corona688:

That's a really good question, but I have to ponder it further before I reply to it.
Meanwhile, I stuck the contents of the man file at SUSE Paste
for your review.

Thank you,

Edit: the project page is at http://code.google.com/p/yad/ with code snippets etc... that may help you help me.

P.S. There's nothing that prevents me from using a zenity progress meter in my code, if that helps.
# 4  
Old 07-07-2011
Oh, I see. You want yad to happen BEFORE your function finishes.

---------- Post updated at 09:16 PM ---------- Previous update was at 09:12 PM ----------

I don't think you can use a yad progress bar AND have yad accept text input at the same time -- how could it tell the difference between the two? Would a text progressbar do?

You don't see to be using yad for anything but displaying text anyway, so why use yad at all?

---------- Post updated at 09:32 PM ---------- Previous update was at 09:16 PM ----------

you could run a separate instance of yad...


Code:
touch /tmp/$$
# echo 1 to start it throbbing
# sleep until the file is deleted, then echo 100 to make it close
# () & to make it run in the background
( ( echo 1 ; while [ -f /tmp/$$ ] ; do sleep 1 ; done ; echo 100 ) | yad --progress --pulsate --auto-close --no-buttons ) &

some_long_command

rm /tmp/$$
wait # for the dialog made earlier to close

This User Gave Thanks to Corona688 For This Post:
# 5  
Old 07-07-2011
MySQL

Corona688:

Perfect solution!!!
it is a thing of beauty. Smilie
Code:
touch /tmp/$$
( ( echo 1 ; while [ -f /tmp/$$ ] ; do sleep 1 ; done ; echo 100 ) | yad --progress --pulsate --auto-close \
--text="Retrieving Snapshots..." --width=150 --title="") & get_snapshots
rm /tmp/$$

Thank you very much.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

If then statement confusion

#!/bin/bash PH=(KD 6S TC 3D) #playerhand TCIP=(AH) #topcard in play A=( "${TCIP::1}" ) # A B=( "${TCIP:1}" ) # H C=8 for e in ${PH}; do if ]; then echo "$e " >> /home/cogiz/validcards.txt else echo... (1 Reply)
Discussion started by: cogiz
1 Replies

2. UNIX for Beginners Questions & Answers

sed confusion

#!/bin/bash X=(0 2 4 6 7 0 0 0 0) Let me just say from the start that sed confuses the hell out of me! In the above line of code how can I use sed to remove all of the 0's except the first one? I have tried sed -e 's/*$//g' but it removes all of the 0's. Thank you in advance for any and... (3 Replies)
Discussion started by: cogiz
3 Replies

3. Shell Programming and Scripting

Confusion with PS

Hello All, I have a problem in counting number of process getting run with my current script name.. Here it is ps -ef | grep $0 | grep -v grep This display just one line with the PID, PPID and other details when i print it in the script. But when I want to count the numbers in my... (11 Replies)
Discussion started by: sathyaonnuix
11 Replies

4. Homework & Coursework Questions

Server Confusion

I don't even know where to start with this one. There is so much out there about different aspects of this. I am starting with a basic Ubuntu 11.04 install. Do I need to configure a DNS? I am a little confused about that. What do I need to do for a domain name? I have followed various tutorials,... (1 Reply)
Discussion started by: polyglot0727
1 Replies

5. UNIX for Dummies Questions & Answers

'tr' confusion

Good day, everyone! Could anybody explain me the following situation. If I'm running similar script: Var="anna.kurnikova" Var2="Anna Kurn" echo $Var | tr -t "$Var" "$Var2" Why the output is : anna KurniKova instead of Anna Kurnikova? :confused: Thank you in advance for any... (2 Replies)
Discussion started by: Nafanja
2 Replies

6. Shell Programming and Scripting

Confusion over a small conditional script

Hi, I was going through a file containing hundreds of lines of codes having conditional statement written as: log() { echo $@ } num=$(/usr/bin/rsh <one_machine> -l root 'ls -d /home/user/db* 2> /dev/null' | wc -w) (( num > 0 )) && log "db info:" so,if here the return value(stored in... (2 Replies)
Discussion started by: amit4g
2 Replies

7. Shell Programming and Scripting

Sed confusion

Hello all, I am trying to delete all the lines in a particular file having a pattern. The problem is that it has special characters and for some reason is not doing the job. For eg. src_file /home/test/filelist.txt :xxxx:ogog /home/test/RCH/ogogogg /home/test/RYHUJ/HHHH... (3 Replies)
Discussion started by: alfredo123
3 Replies

8. UNIX for Dummies Questions & Answers

wc command confusion

Can somebody explain it to me that why wc gives more chars suppose Ab.txt have two lines qwer qasd then wc -c ab.txt will give 10.why not 8.okay may be it is taking count one for each line just in case but why echo "qwer"|wc -C gives 5. Ok with \c it is returning 4. :) (6 Replies)
Discussion started by: Dhruva
6 Replies

9. UNIX for Dummies Questions & Answers

ISO Confusion?

Hiya folks, Just a quick question. When I am ready to download Fedora core 4, do I need to download all 4 ISO files? Or just one, I think myself it would be all 4 but dont want to sit and wait around if I only need to download one. Also after downloading the Iso files, do I burn one file to one... (6 Replies)
Discussion started by: Mr_Pinky
6 Replies
Login or Register to Ask a Question