how do you set an env variable from within a csh script?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how do you set an env variable from within a csh script?
I'm creating a job system that will allow users to create a new "job". It essentially makes a whole bunch of directories and creates/modifies a whole bunch of environment variables. The environment variables are determined by user input when they run the script (one of the command line arguments).
If I simply use "setenv FOO BAR", the variable FOO is only set for the duration of the script. How do I make it persist? I've read that I could use the '.' command to launch another file from within my script, but then how would I get the user input to that file?
I'm making a csh script just because I'm more familiar with csh. I suppose I could use bash if this becomes easier in bash.
Basically shell variables aren't persistent. If you
need that feat. you may have to look into a bit
more of coding and read/write the required values
from/to files, I guess.
Basically shell variables aren't persistent. If you
need that feat. you may have to look into a bit
more of coding and read/write the required values
from/to files, I guess.
Cheers,
Tink
but if I setenv in a shell, that shell has that variable set until I close it. Why can't I have a script set the variable for the shell it was launched from?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.