cgray1223
asked on
Unix Command to set Environment Variables
Hello,
I'm trying to setup some environment variables on Unix and I believe I need to use the source command to "source" a file. The .sh file I'm trying to source contains a bunch of export commands likes the below. When I run $ source setenv.sh I get the below output. I've removed all commands except for the ANT_HOME export and I still get the following error, any ideas?
output from $ source setenv.sh:
ANT_HOME=/auto/energywise/ apache-ant -1.8.2: Command not found.
export: Command not found.
setenv.sh contents:
ANT_HOME=/aut/ew/apache-an t-1.8.2
export ANT_HOME
I'm trying to setup some environment variables on Unix and I believe I need to use the source command to "source" a file. The .sh file I'm trying to source contains a bunch of export commands likes the below. When I run $ source setenv.sh I get the below output. I've removed all commands except for the ANT_HOME export and I still get the following error, any ideas?
output from $ source setenv.sh:
ANT_HOME=/auto/energywise/
export: Command not found.
setenv.sh contents:
ANT_HOME=/aut/ew/apache-an
export ANT_HOME
ASKER
that yields:
$ . ./setenv.sh
/router/bin/.: Permission denied.
$ . ./setenv.sh
/router/bin/.: Permission denied.
did you give execute permission to setenv.sh?
chmod +x setenv.sh
chmod +x setenv.sh
ASKER
I believe these are correct:
-rwxr-xr-x 1 colgray eng 1020 Nov 2 10:12 setenv.sh
the directory its trying to use for the export (/aut/ew/apache-ant-1.8.2) has the below permissions, is that the problem?
drwxr-xr-x 6 darmak eng 4096 Dec 20 2010 apache-ant-1.8.2
-rwxr-xr-x 1 colgray eng 1020 Nov 2 10:12 setenv.sh
the directory its trying to use for the export (/aut/ew/apache-ant-1.8.2)
drwxr-xr-x 6 darmak eng 4096 Dec 20 2010 apache-ant-1.8.2
Ok, put quotes
setenv.sh contents:
#!/bin/bash
export ANT_HOME="/aut/ew/apache-a nt-1.8.2"
setenv.sh contents:
#!/bin/bash
export ANT_HOME="/aut/ew/apache-a
ASKER
same thing.
ASKER
looks like it was using the wrong command as I'm using c shell and the command needs to be setenv name value
First thing. You probably do not have your path set correctly or something. In particular, try running this command
export a=
On the command line. If this produces an error, I want to see what error message it is.
Second, which shell are you using?
If you were not using bash, remove #!/bin/bash from the file
export a=
On the command line. If this produces an error, I want to see what error message it is.
Second, which shell are you using?
If you were not using bash, remove #!/bin/bash from the file
Oops.
Yes, I was considering bash/ksh.
Yes, I was considering bash/ksh.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
it is clear that you are using csh.
you need to convert your env variables settings in csh format:
e.g.
setenv PATH /usr/bin:/usr/ucb:/usr/loc al/bin
setenv PATH ${PATH}:~/bin
or
set path = ( /usr/bin /usr/ucb /usr/local/bin )
then in your .login file run
source ./setenv.sh
you need to convert your env variables settings in csh format:
e.g.
setenv PATH /usr/bin:/usr/ucb:/usr/loc
setenv PATH ${PATH}:~/bin
or
set path = ( /usr/bin /usr/ucb /usr/local/bin )
then in your .login file run
source ./setenv.sh
I think you can not do below in csh
. ./setenv.sh
. ./setenv.sh
setenv.sh contents:
#!/bin/bash
export ANT_HOME=/aut/ew/apache-an
And call it like
. ./setenv.sh