Setting a locale in Redhat ES 4

Hi,

I am writing a shell script which would ask user to select a locale and should set the locale for them.

In the script I am doing

export LANG=<user selected locale>

and i do 'locale' it would show me the changed locale.

But, when I come out of the program and do 'locale' it would go back to previous one.

Is there anyway I can avoid this?

Thanks,
sunny.

A script cannot modify the environment of the parent process; you need to somehow invoke your command in the context of the invoking shell.

Some tools require you to invoke them with something like eval `nameoftool` and so the tool itself would simply print something like LANG=value; export LANG and leave it to the invoking user to actually do something useful with this output.

When you run a script in a shell, it runs in a subshell and a parent shell can't inherit variables from a subshell.

Run your script in the current shell:

. ./scriptname

Thanks a lot