Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 14th, 2004, 2:32 PM   #1
elmo
Newbie
 
Join Date: Oct 2004
Posts: 4
Rep Power: 0 elmo is on a distinguished road
alright, i got some code like this:

function foo() {
  echo "var: $var"
}

function bar() {
  for i in `seq 10 10 100`; do
     var=$(($var + $i))
     echo $i
  done
}

bar
foo

this will set var to some value, and echo $i

if i try to add some nifty stuff to the second function

...
function bar() {
  for i in `seq 10 10 100`; do
     var=$(($var + $i))
     echo $i
  done | dialog --gauge "ra ra ra" 10 20 0
}
...

the gauge will work, but var wont be set to anything due to variable protection (or some such).

Is there any way around this, so that var will be accesible in foo()?
elmo is offline   Reply With Quote
Old Feb 28th, 2005, 5:11 PM   #2
Vorlin
Newbie
 
Join Date: Feb 2005
Posts: 12
Rep Power: 0 Vorlin is on a distinguished road
Change the
done | dialog --guage "ra ra ra" 10 20 0
to
done && dialog --guage "ra ra ra" 10 20 0
. The | declares you to send the output from the previous command when nothing was passed from the for loop.
__________________
--Vorlin

"Systems administration - it's not just my job, it's how I buy video games!"
Vorlin is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:34 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC