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!

Passing variables from and to scripts

Status
Not open for further replies.

tpbjr

MIS
Oct 8, 2004
120
US
I am trying to pass a variable from one script to another and then back to the caller. I have used the EXPORT MY_VARIABLE=0 for example.

Then called a script, lets say Test2.ksh and changed the MY_VARIABLE to 1 inside Test2.ksh and when I get back to Test1.ksh and echo $MY_VARIABLE it displays 0 (the original value).

Is there a way to do what I am trying to do?

Thank you in advance.

Thank you for all your help

Tom
 
Source the second script:
. Test2.ksh

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
AaaHHHH,:)

Now that I have moved on to the actual script I need to work. I get the following....

costapp/batch/scripts/costweeklyend_tom.ksh[25]: EXPORT: not found

It it a problem to use EXPORT from lets say the second or third script in. Example: Script1 calls Script2 I use the export in script2 and call script with like this, . script3.



Thank you for all your help

Tom
 
The correct name of the builtin function is export (not EXPORT)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Type-O -- Sorry!

Now I have gotten passed all those issue thanks to you but I have another major issue...

Script1, calls scripts2 and then script2 calls scripts3 (. $MYPATH/script3)

Now when script3 is done the control does not go back to script2, instead it is jumping back to script1.

My IF logic in script2 that checks the value never gets executed. I know this because I put an echo directly under the call to script3.

An addition test: I called script2 from script1 as . $MYPATH/script2 then script3 as . $MYPATH/script3.

After script3 was done the execution stopped. It never returned to script2, then script1.


I really appreciate all your help.

Thank you for all your help

Tom
 
In reference to my issue above:

I am almost thinking that it would be easier to just create an empty dummy file. Then check if it exists. If it does
do my logic else do my other logic.

This way I will check for the existance at the beginning of the script and if it exists I will remove it (clean up).

Can you help me with that. I will begin to look in the book on how to check for an existance of a file. I know I had seen an example of the if statement checking for an existance of a file.


Thank you for all your help

Tom
 
man test

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
the test command worked just fine for me.
My hat is off to you PHV for all your help
I really appreciate it.

Thank you for all your help

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top