Reputation: 1896
We have few executable which need some environment setting. We manually running those scripts before running the executable
Like
$ . setenv.ksh
We have to encompass call these in one script to avoid the manual work. We written a sh script like
#!/bin/sh
. setenv.ksh
./abc &
Still the environments are not setting in that session. I think the “. setenv.ksh” runs with fork and it’s not setting the environment.
Please me to solve this problem. Which command we use to run the setenv.ksh so, this will work fine.
Thanks
Upvotes: 1
Views: 992
Reputation: 107879
I notice the environment script is called setenv.ksh
but you try to run it from /bin/sh
. Maybe your system has a shell other than ksh as /bin/sh
and it misparses something it setenv.ksh
. Try changing the shebang line to #!/bin/ksh
(or whatever the path to ksh is on your system).
Upvotes: 1
Reputation: 6387
In setenv.ksh, you need to export all environment variables you set so that any sub-shell will inherit the values:
export MYENV=myValue
Upvotes: 1