Linked Questions

13
votes
0answers
35k views

how to set environment variables from a shell script? [duplicate]

I'm trying to set environment variable through a shell script. Here is the script with various techniques: #!/bin/sh echo "export SOMEPATH=/root/some" >> /root/.bash_profile echo "export PATH=$...
2
votes
1answer
3k views

How can I set environment variable permanently through shell script? [duplicate]

Let's say I have a script: #!/bin/bash echo "$1" if [[ ! $1 ]]; then echo "True" fi export ABC="/home/aashish" ABC is not available after the execution of this script. How can I make that ...
0
votes
1answer
1k views

Shell script executing in the terminal but not from shell script file [duplicate]

Possible Duplicate: How can I make variables “exported” in a bash script stick around? I have a problem with executing script from file. When I type in command line PATH=$PATH:/home/...
2
votes
1answer
4k views

How to export an environment variable from .sh file in zsh? [duplicate]

I have the following shell script TEST=/foopath export TEST It is in a file called test.sh and on which I ran chmod +x test.sh When I run ./test.sh I expect that I can then execute echo $TEST and ...
0
votes
2answers
2k views

Save command output as environment variables [duplicate]

If the command my_command has this output: VAR1=some_value VAR2=other_value is it possible to call my_command from a shell script so that both VAR1 and VAR2 are saved as environment variables? I ...
1
vote
1answer
2k views

Bash command does not execute from script, but works when entered in terminal [duplicate]

I have some strange problem with a very simple script. I am setting LD_LIBRARY_PATH for a library. When I type this command in terminal: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/some/path echo $...
1
vote
1answer
1k views

Script that exports enviromental variables cannot export them [duplicate]

I have the following script named export.sh: #!/bin/bash SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink DIR="$( cd -P "$( dirname "$...
0
votes
1answer
944 views

Setting proxy environment variables in a shell script [duplicate]

I am trying to set a proxy on a rotating basis; but my export commands are not working. I'm using CentOS 7. I've gone back to basics and tested a really simple bash script, which sets and unsets ...
1
vote
2answers
390 views

setting bash shell varible to pwd [duplicate]

I'm trying to set a shell variable to $PWD - the path from were the script is executed. This is what I have, setenv.sh: #!/bin/bash export WORK_AREA=$PWD #also tried "$PWD", $(pwd), `pwd` But ...
0
votes
1answer
269 views

Bash environment variables not setting [duplicate]

I am trying to configure the AWS CLI using a bash script. I have the below in my script and it will not set the values. When I echo out the variables names it just shows a blank line. script code ...
0
votes
1answer
114 views

Linux why do i have to run commands instead of running the bash file [duplicate]

In order to run an executable file, I need to run all the commands in the below bash file first, so I just put those commands in the bash file and run the bash file first, but running the bash file ...
0
votes
1answer
184 views

Trying to export a path from inside a bash script [duplicate]

I am trying to put my whole environment set up into a single bash file. I am only hitting one issue. When I try to export a new path from inside the file it is not setting the path in the environment ...
0
votes
3answers
129 views

Bash: shell script create variables? [duplicate]

I'm trying to have a bash script create a variable and have the variable persist in the terminal until the terminal closes (not permanently). I thought export was what I needed but it didn't work. #!/...
0
votes
2answers
60 views

How to remove first segment or segments from PATH in shell script [duplicate]

I wanted to remove a CUDA directory from PATH by a sh script. The directories are showed by doing echo $PATH /usr/local/cuda-9.0/bin:/usr/sbin:/usr/bin: I want only: /usr/sbin:/usr/bin: My script ...
2
votes
1answer
50 views

Keep sourced file after script execution [duplicate]

Is it possible to keep source from an executed script without sourcing it ? Here is the script install.sh: JJJ=bar When i execute the script like ./install.sh, after execution, i got the following ...

15 30 50 per page