Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script questions 1

Status
Not open for further replies.
Mar 31, 2004
151
US
Could anybody tell if there is a way to return values from nested function calls?

Ex: if something then
return 1
else
return 0
fi

func1 --- func2 ---- func3. Action needs to be taken at func1 when something happens in func3. Currently I am using the above way in both func3 and func2. Is it the only way to do it?
 
You may consider to play with a global variable set in func3 and tested later in func1.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Thanks. Normally global variables should not be used. Is it permissible to use in such a context? OR Can I go with the above approach. Which is preferrable?
 
Normally global variables should not be used
???
 
Sorry! I was not referring to shell scripting. I was talking in general sense. In oop, global variables are generally not preferred due to security concerns....
 
I meant global variable in the scope of the script (no need to export them) versus a local variable with scope limited to the function.
Hope that make sense.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Code:
   write header to file   
   connect sqlplus spool to sqltemp
   cat $sqltemp |  print $1, $2, $3}' | while read x y z
   do
   if something then 
   write output to file
   fi
   done

Header should be written only if there is sqlplus output. Header can't be put in loop because it repeats.
 
cat $sqltemp | print $1, $2, $3}' | while read x y z
Can't figure out how this code above works !
BTW, it would be preferable to start a new thread as this seems to be a different question.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top