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 of variables in Bourneshell

Status
Not open for further replies.

Rezabash

Programmer
Aug 17, 2002
3
NO
How do I export and import a given variable among several bourne shell scripts ? I would like to be able to be able to update the variable in several different scripts.
 
Hi:

I don't understand your question completely. If a parent script calls a child as in this example:

#!/bin/sh
# parent.ss

vara=/usr/bin; export vara
echo "calling a.ss"
a.ss
echo "calling b.ss"
b.ss
# end example

the two child scripts inherits the parents shell including variable vara provided vara is exported.

(if you're interested, check out thread 822-255445 for a discussion on how a child shell can change the parent).

Regards,


Ed




 
How could I find Thread nr: 822-255445 ?
Could any body post it to me ?
 
I think there's a extra space in the address. Just try clicking on:

thread822-255445

Cheers.
 
If you want the parent to inherit any of the child's variables (that you set in the child script) execute the child script as follows:

#
# parent script
#
. child_script
#
#

Note: its "." space, then your child script.

Anything set in the child should stay in effect when you return from the child.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top