Zenity, While, and Conditions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Zenity, While, and Conditions
# 1  
Old 10-25-2012
Zenity, While, and Conditions

All,

I'm having fighting a losing battle with what I though would be simple.

My goal is this: Show a zenity progress or info dialog until the system obtains an ip address, then close the dialog and continue through the rest of the script.

Right now I've got the following:

Code:
ip=`ifconfig | grep 'inet ' | grep -v -c '127.0.0.1'`

just grabbing the number of ip addresses.

Code:
if [ $ip -eq 0 ]; then
while [ $ip -eq 0 ]
do
     ip=$(ifconfig | grep 'inet ' | grep -v -c '127.0.0.1')
     zenity --info --no-wrap --text "You are not currently connected to the internet. Please check your router and connections"
else
     pkill zenity
done
fi

Now I thought I was dictating that if the number of ip addresses is 0, keep checking until it isn't; also show a zenity dialog. Then, when the number no longer equals 0, exit the loop and kill the zenity box. With the exception of zenity automatically closing, everything else works, as if I switch to echoing right in the terminal it works perfectly. I think this could be useful for a lot of different applications requiring user action, but not requiring an explicit "ok" from the user after the action has been taken.

Anyone care to educate me?

---------- Post updated 10-25-12 at 10:09 AM ---------- Previous update was 10-24-12 at 06:11 PM ----------

Bump.

Have I stumped this forum as well?
# 2  
Old 10-25-2012
try moving lines:
Code:
else
     pkill zenity

after line:
Code:
done

# 3  
Old 10-25-2012
rdrtx1,

Thank you, I appreciate you taking the time to respond. I've just now found a solution similar to what you recommended.

Rather than using 'if' at all I've managed to fit it all into a 'while'

Code:
while [ $ip -le 0 ]
do
        ip=$(ifconfig | grep 'inet ' | grep -v -c '127.0.0.1')
        sleep 2
        echo checking
done | zenity --progress --pulsate --auto-close

Much shorter, and not doing any nasty pkills. Hopefully someone else will find this useful as well. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

New to Linux, using zenity need some help

Hello all, I am using zenity for my final project in class and need some help. I am trying to create a text based game and in this game you pick up items, I want to store those items in a .txt file and be able to recall them later and remove a SPECIFIC item from the list after it has been... (4 Replies)
Discussion started by: papgizmet
4 Replies

2. Shell Programming and Scripting

Errors in if conditions with to many OR conditions

Hi ALL I have a script where in i need to check for several values in if conditons but when i execute the script it throws error such as "TOO MANY ARGUMENTS" if then msg="BM VAR Issue :: bmaRequestVAR=$bmaRequestVAR , nltBMVAR=$nltBMVAR , bmaResponseVAR=$bmaResponseVAR ,... (10 Replies)
Discussion started by: nikhil jain
10 Replies

3. Shell Programming and Scripting

Zenity help

I have a large system housekeeping script, that I want to use with zenity. One of the processes will be to conduct a virus scan, which I can easily do with something like: clamscan -rv / | zenity --text-info --width 640 --height 640 The problem is that it needs user intervention by... (2 Replies)
Discussion started by: stumpyuk
2 Replies

4. Linux

Zenity function

i wanted to put this code on a list zenity but it never worsk, how would i be able to do that? cd /home/mint ls -d */ (3 Replies)
Discussion started by: roozis
3 Replies

5. UNIX for Dummies Questions & Answers

using an array with zenity

I got an array: for i in $(fdisk -l | awk '/Disk\ \/dev\/d/ { print $2 }') ; do drive_list="$i" # echo "$i" ((index++)) done #>/dev/nullI got this zenity code: grub_dev=$(zenity --list --title="Hard Drives" --text="Choose exactly one drive to use for the GRUB bootloader.... (2 Replies)
Discussion started by: tornow
2 Replies

6. Shell Programming and Scripting

file zenity

Hello, I have a script with zenity file, but I want to know the file name and path, but this way I just take the name of the file. fl1=`zenity --file-selection --title="Seleccionar fichero"` basename $fl1 .txt > temp nom=`cat temp` Thank you very much (1 Reply)
Discussion started by: uri_crack
1 Replies

7. Shell Programming and Scripting

Zenity and IF/ELSE cond'.

Hey guys i wrote this code but it wont give me anything. any ideas? ans=$(zenity --list --text "Do you want to set USER/GROUP quota?" --radiolist --column "Choice" --column "Desc" TRUE Hi FALSE Bye); echo $ans if ; then ./example.sh else exit fi (2 Replies)
Discussion started by: dplate07
2 Replies

8. Shell Programming and Scripting

Zenity Menu

I have some troubles with zenity and menu. I seach for: MAIN MENU CHOICE 1 "do something" CHOICE 2 "do something 2" CHOICE 3 "do something 3" But then in "do someghing " when i click i want to return to the MAIN MENU So something like: while true; do ... (4 Replies)
Discussion started by: aspire
4 Replies

9. UNIX for Dummies Questions & Answers

zenity --question help

Hello I've a script where I've a zenity --question because I want to ask the user if he is sure that he wants to delete the file. The problem is, if the user says "OK" it deletes nad if the user says cancel it deletes :) How can I close the script if the user says cancel?? thanks (3 Replies)
Discussion started by: ruben.rodrigues
3 Replies

10. Shell Programming and Scripting

Zenity

Hi! does someone know how can I setup a zenity entry "box" such that comes with the data as default. like it appears an entry box already with the data but it can be modify. thanks (2 Replies)
Discussion started by: ruben.rodrigues
2 Replies
Login or Register to Ask a Question