Ok I fixed it (already had a printmessage subroutine that 'tee'd to LOGFILE so I replaced any printf statements with printmessage statements in a couple routines). I removed the tee from the call to main and SUBJECT simply became global. Now I don't need to return SUBJECT at all, or pass it to cleanup, (expected behavior). But it seems as though this is defeating the my original purpose of using subroutines, (kind of) ... I was trying when possible to call any function with tee ( function | tee -a $logfile) and avoid doing that with each printf statement or continuously calling my printmessage routine. Calling the function and piping through tee works of coursce except when you want to parameterize or pass variables back and forth. It is at this point where my idea could use a little tweaking from others that have more experience redirecting the various streams, ie &1, &2, &3, &4, etc. Joel Patterson Database Administrator 904 727-2546 ________________________________ From: Niall Litchfield [mailto:niall.litchfield@xxxxxxxxx] Sent: Thursday, June 25, 2009 8:16 AM To: Patterson, Joel Subject: Re: Korn shell function paramter passing or if you're like me you've typoed it somewhere and can't see it :( On Thu, Jun 25, 2009 at 1:15 PM, Niall Litchfield <niall.litchfield@xxxxxxxxx> wrote: other reasons, less common * you've called the main function either in the background or some other way that forks a new shell (eg a pipe). * according to http://www.bolthole.com/solaris/ksh-functions.html you can get this when you use backticks - never done this myself. On Thu, Jun 25, 2009 at 1:11 PM, <Joel.Patterson@xxxxxxxxxxx> wrote: No. Joel Patterson Database Administrator 904 727-2546 ________________________________ From: Niall Litchfield [mailto:niall.litchfield@xxxxxxxxx] Sent: Thursday, June 25, 2009 8:07 AM To: Patterson, Joel Cc: oracle-l@xxxxxxxxxxxxx Subject: Re: Korn shell function paramter passing are you using typeset to define local variables by any chance? Niall On Thu, Jun 25, 2009 at 1:00 PM, <Joel.Patterson@xxxxxxxxxxx> wrote: Joel Patterson Database Administrator 904 727-2546 This one I'm spending to much time on. I have a korn shell script. #!/usr/bin/ksh Do some initialization commands Call a function startlogfile Call function 'main' main calls function runsomething Runsomething initializes and returns "${SUBJECT}" main can print ${SUBJECT} main returns ${SUBJECT} (or "${SUBJECT}", or ASUBJECT=${SUBJECT} successfully ${ASUBJECT}, or "${ASUBJECT}" outer most shell cannot print $SUBJECT what's going on? Thanks, -- //www.freelists.org/webpage/oracle-l -- Niall Litchfield Oracle DBA http://www.orawin.info <http://www.orawin.info/> -- Niall Litchfield Oracle DBA http://www.orawin.info <http://www.orawin.info/> -- Niall Litchfield Oracle DBA http://www.orawin.info