I am working with Sun Solaris 9 and I want to export the environment variable from my application(xxxx.ksh) but I am not able to see it when I am using SET command
I am writing some variables which I have to set
COMMON_USER_HOME=${HOME}
export COMMON_USER_HOME
echo COMMON_USER_HOME=$COMMON_USER_HOME
export P4USER="AbcdeF"
echo P4USER=$P4USER
but when I am running my file xxxx.ksh and echoing the variable then I am able to see the output of the variable but not able to see it as exported when using set commond
# echo $SHELL
/bin/sh
COMMOM_USER_HOME=/home/User1
P4USER=AbcdeF
So Can anyone tell me what is the problem and how can I salve it
Thanks in Advance...
Run (source) your script with the environment variables in the current shell:
. ./script_with_variables
Regards
I am not able to execute the script by
. filename.ksh
or . ./filename.ksh
I am able to run any script using
ksh filename.ksh
Why not? It should not be a problem if you make the file executable (chmod).
With "ksh filename.ksh" you're starting the script in a new shell (child) and all variables you've set are lost if the script exits. The parent shell don't inherit anything from the child.
Regards
yes,I made the file executable (chmod).but afterthat I am not able to execute it.when I am executing it by
#ls -l
-rwxrwxrwx 1 root other 5338 Sep 29 13:16 profile.ksh
# ./profile.ksh
./profile.ksh: bad substitution
# . ./profile.ksh
bad substitution
Post the contents of profile.ksh.
Regards
make sure there's no ^M characters in a script file: cat -vet profile.ksh
if there're control chars, "man dos2unix"