Help in Setting Environment variables in TCSH

Hello All,

I am writing a script to set some environment variables which are required for a particular application. I understand that the environment variables set by Shell script can, at the max, be valid for the session. They will have to be set again once the session is closed and re-opened.

In my case, I can see that the environment variables are being set, but once the shell script execution completes, the environment variables are not set.

******************
#!/usr/bin/env tcsh
setenv SR_MGR_CONF_DIR /users/abc/tools

echo $SR_MGR_CONF_DIR

******************
I see the output of the echo is right... but if i execute the same echo command after the execution of the script, I am not able to see the environment variable.

Please let me know why is this so.

Thanks in advance
Regards
Sandeep

The shell script is sourced by a different shell, not the one you invoke it from. The shell exits when its done executing the shell script. So its a different session. Hence you won't be able to access the variables set in a shell script. So you'll need to set env variables in your shell from which you invoke the shell script. And you;ll be able to use the variabels in your shell script. Or you can set it in your .profile or .${SHELL}rc .