> > Hi ppl, > As far as I did not find the answer in bash manual, I hope that > someone can help me here. Let say I have two bash scripts and I need the > parameter which is set in scr2 to be visable in scr1. > > scr1: > #!/bin/sh > export LANG=lang1 > echo "LANG is $LANG in $0 " > scr2 > echo "LANG is $LANG in $0" > scr2: > #!/bin/sh > echo "LANG is $LANG in $0 " > export LANG=lang2 > echo "LANG is $LANG in $0" > > However the output is : > LANG is lang1 in ././scr1 > LANG is lang1 in ./scr2 > LANG is lang2 in ./scr2 > LANG is lang1 in ././scr1 > ^ > ... so I have got here the old value of LANG. > The question is it possible to get the NEW value which is assigned in > scr2?
Yes. You need to source the script instead of executing it in a separate shell. Then scr2 can actually be viewed as a part of scr1, but only contained in another file. You source a script with the `.' command: . scr2 The problem with this is that nothing in scr2 is separated from scr1, so the usefulness of having two scripts is gone. As an alternative you could let scr2 print the new value, like scr2: #!/bin/sh export LANG=lang2 echo $LANG scr1: #!/bin/sh export LANG=lang1 echo $LANG LANG=`scr1` echo $LANG But this may not be what you want. The `export' command only works `downward': the exported variable is put in the environment of shells and programs called from the shell where it is used. HTH, Eric -- E.L. Meijer ([EMAIL PROTECTED]) | tel. office +31 40 2472189 Eindhoven Univ. of Technology | tel. lab. +31 40 2475032 Lab. for Catalysis and Inorg. Chem. (TAK) | tel. fax +31 40 2455054