LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   how do you set an env variable from within a csh script? (http://www.linuxquestions.org/questions/linux-general-1/how-do-you-set-an-env-variable-from-within-a-csh-script-185881/)

BrianK 05-25-2004 09:25 PM

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.

Tinkster 05-25-2004 09:34 PM

It doesn't, though.

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

BrianK 05-26-2004 01:35 PM

Quote:

Originally posted by Tinkster
It doesn't, though.

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?

Tinkster 05-26-2004 02:16 PM

man bash
/COMMAND EXECUTION




Cheers,
Tink


All times are GMT -5. The time now is 08:27 AM.