> - -------------- test.sh ------------------ > export MY_VAR="SOME_VALUE" > echo "$MY_VAR" > - -------------- test.sh ------------------ > later: chmod +x test.sh then run this script: ./test.sh > > but when try to use this variable in my environment I can't do, if write > "env" the nev variable MY_VAR doesn't appear ... I think that there are some > protection about export variables, but how do I can export variables? The environment of a process cannot easily be changed from outside that process once the process has started running. This means that exporting a variable does not do the obvious thing: if you run a shell script, which tries to export a variable, then that variable will only be exported to processes which are spawned by that shell script. In particular, if test.sh contains
export WIDGET=wobble then running test.sh will have absolutely no effect on the environment of the shell which invoked it. If you need to change a running shell's environment through a script, then you need to get that shell to source rather the script rather than to execute it. To do this, go $ . ./test.sh This causes the shell to run test.sh as if it had been typed in at the command line, rather than spawning an entirely independent shell and running test.sh through that. Steven Smith, [EMAIL PROTECTED]
msg03139/pgp00000.pgp
Description: PGP signature
