Selon Ken Irving <[EMAIL PROTECTED]>: > On Tue, Apr 20, 2004 at 10:41:15AM +0200, [EMAIL PROTECTED] wrote: > > > > Hello, > > > > >From the command line, export works as I expect, but when I execute an > export > > command by launching a script, it doesn't work as I expect. > > > > Example: > > > > % cat try_it > > export VARIABLE=ItWorksFineImHappy > > % export VARIABLE=DoesntWorkImConfused > > % echo $VARIABLE > > DoesntWorkImConfused (so far, so good) > > % chmod +x try_it > > % ./try_it > > % echo $VARIABLE > > DoesntWorkImConfused > > > > Did I miss something fundamental? > > I couldn't find the answer until now... Please help. > > > > Sylvain. > > Export works to pass variables to subsequent command environments; the > try_it script would see the the right value, and so would any scripts > (or shells) that it ran. But you're in the current environment, > and a script that you run cannot modify it. Each command is passed a > copy of the environment; export makes variables persist into that copy. > It is possible to run a script to set your current variables, but not by > running the script; rather "source it" to the current shell by using the > "." or source command. > > Good luck!
Thank you guys! I've learned something useful. The 'unexpected' behaviour was: % ./try_it % echo $VARIABLE DoesntWorkImConfused Now I know why it is so. The solution you gave me is: % . ./try_it Or as well: % source try_it % echo $VARIABLE ItWorksFineImHappy Cheers, Sylvain. > > -- > Ken Irving, Research Analyst, [EMAIL PROTECTED], 907-474-6152 > Water and Environmental Research Center > Institute of Northern Engineering > University of Alaska, Fairbanks > -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]