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!

export Question?

Status
Not open for further replies.

pmcmicha

Technical User
May 25, 2000
353
I am running the following script which is spawned from another running script and I need to access the variables in the original script, but cannot seem to do so....

Spawned Script:
#!/usr/bin/ksh -p

TZ=TZ+216
DCOUNT=1
for TIME in 216 192 168 144 120 96 72 48 24
do
TZ=TZ+${TIME}
DAY[${DCOUNT}]=`/usr/bin/date "+%A"`

if [[ "${DAY[${DCOUNT}]}" == "Sunday" ]]
then
let DCOUNT=DCOUNT
else
export "${DAY[${DCOUNT}]}"
let DCOUNT=DCOUNT+1
fi
done
#EOS

Now in the original running script, I just want to print the ${DAY[${COUNT}]} out 7 times with the correct days.

SHELL=KSH 93
UNIX Version: SCO UNIXWARE 7.1.1

Thanks in advance.
 
How do you call the 'spawnned' script?

. /path2/spawnedScript.sh vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Vlad,

Yes, I call it with the full path, but not with the period.

DIR=/whatever/temp

# Start FindDay.ksh script here.

${DIR}/FindDay.ksh

Then I am trying to pull the ${DAY[${DCOUNT}]} variables back over for the days I want to see.
 
Call it with the leading period and a space, that will run the script in the same process as the calling (the parent) script.

Any variable you change in your script will be visible in your parent script.

Alternatively..... (Because it's a bit risky doing that, you will end up overwriting some important value in your main script)

Write the values you need out to a file, and read that file into your main script. Mike
________________________________________________________________

&quot;Experience is the comb that Nature gives us, after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top