Hi,
I wrote two small scripts to set env variables in a shell.
java_env.csh
#!/bin/csh -fn
setenv JAVA_HOME '/scratch/software/jdk1.5.0_11'
setenv PATH $PATH':'$JAVA_HOME'/bin'
and run it using csh ./java_env.csh
But the env variables are not set. I tried running each line on the shell window directly and I can see the variables being set.
I also tried java_env.sh
#!/bin/sh -n
set JAVA_HOME='/scratch/software/jdk1.5.0_11'
set PATH=$PATH':'$JAVA_HOME'/bin'
This as well didn't work.
Please suggest.
thanks
Amod
source ./java_env.csh
. ./java_env.sh
Thanks for the help.
source ~/Desktop/java_env.csh worked for me.
Though for sh I got this error
. ~/Desktop/java_env.sh
/bin/.: Permission denied.
Could you please provide pointers on the usage.
-- Amod
#!/bin/sh -n
set JAVA_HOME='/scratch/software/jdk1.5.0_11'
set PATH=$PATH':'$JAVA_HOME'/bin'
Why exactly do you have quotes?
Why do you have '-n'?
Without the quotes it was not working for the csh script. I carried the script to sh.
Could you help me understand why?
Also help me understand why $ csh ~/Desktop/java_env.csh does not work but $ source ~/Desktop/java_env.csh works?
From my sh script i tried removing ' but still the same problem.
I removed the -n flag but no luck.
#!/bin/sh
JAVA_HOME='/scratch/software/jdk1.5.0_11'
PATH=$PATH:$JAVA_HOME/bin