Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
update
Source Link

I am using csh scripts for some automation purpose. I have a number of scripts, and the beginning of all of which I need to set a fixed set of environment variables.

|----SCRIPT 1---|     |----SCRIPT 2---|
|# set env vars |     |# set env vars |
|               |     |               |
|# do something |     |# do something |
|               |     |# else         |

So I thought that I'll put all the environment variables in another script and source it from each file. But as it turns out, environment variables set inside the sourced script are not reflected outside. Is there any clean way to achieve what I want? Or do I have to explicitly set environment variables in each script ?

UPDATE :

While sourcing the file, I was piping the output to a file using the 'tee' command. I noticed that after removing the pipe, the script file worked.

I am using csh scripts for some automation purpose. I have a number of scripts, and the beginning of all of which I need to set a fixed set of environment variables.

|----SCRIPT 1---|     |----SCRIPT 2---|
|# set env vars |     |# set env vars |
|               |     |               |
|# do something |     |# do something |
|               |     |# else         |

So I thought that I'll put all the environment variables in another script and source it from each file. But as it turns out, environment variables set inside the sourced script are not reflected outside. Is there any clean way to achieve what I want? Or do I have to explicitly set environment variables in each script ?

I am using csh scripts for some automation purpose. I have a number of scripts, and the beginning of all of which I need to set a fixed set of environment variables.

|----SCRIPT 1---|     |----SCRIPT 2---|
|# set env vars |     |# set env vars |
|               |     |               |
|# do something |     |# do something |
|               |     |# else         |

So I thought that I'll put all the environment variables in another script and source it from each file. But as it turns out, environment variables set inside the sourced script are not reflected outside. Is there any clean way to achieve what I want? Or do I have to explicitly set environment variables in each script ?

UPDATE :

While sourcing the file, I was piping the output to a file using the 'tee' command. I noticed that after removing the pipe, the script file worked.

Source Link

Setting environment variable using shell script

I am using csh scripts for some automation purpose. I have a number of scripts, and the beginning of all of which I need to set a fixed set of environment variables.

|----SCRIPT 1---|     |----SCRIPT 2---|
|# set env vars |     |# set env vars |
|               |     |               |
|# do something |     |# do something |
|               |     |# else         |

So I thought that I'll put all the environment variables in another script and source it from each file. But as it turns out, environment variables set inside the sourced script are not reflected outside. Is there any clean way to achieve what I want? Or do I have to explicitly set environment variables in each script ?