How to set gobal enviroment vaibles in HPUNIX

Hi ,

I have one script setting envrioments varaible , calling this scripts in another script,i wnat to user thoese envrioemnt variables in parent script.

I am trying set envrioment variables with "export" comand i am unable to access thoese envrioment variables.

$ cat dm_env21
DM_TK_DB=MICDEV1B;export DM_TK_DB
test=SVWMIG1B;export test
echo $?
echo $DM_TK_DB

I want DM_TK_DB,test varibles in test.sh scripts

$ cat test.sh
#!/bin/ksh
sudo su - micdev1b << EOF
cd /m61/micdev1b/work/dm/scripts
. /m61/micdev1b/work/dm/scripts/dm_env21
echo $?
#echo $DM_TK_DB
echo $test
EOF

I am runing test.sh with my user and i have sudo permission on micdev1b.

I am runing tihs test.sh script i am getting DM_TK_DB,test variable contains null values.

Could u please help me.

use the "-c" switch of su to execute commands. Even then i suppose that using sudo, su AND a here-document in one line might be too much for the shell to parse.

Try it the following way:

sudo su - <user> -c <script>

Where <script> contains the here-document. If nothing else this will at least make it easier to find out where the problem really is.

I hope this helps.

bakunin

if we want run script with sudo su - <user> -c <script>[/code] this scname should added into sudo configration files(i am not sure file name).

$ sudo su - micdev1b -c /m61/micdev1b/work/dm/scripts/run_dms70_10_atai_dbanalyze.sh
Sorry, user rsiddaba is not allowed to execute '/usr/bin/su - micdev1b -c /m61/micdev1b/work/dm/scripts/run_dms70_10_atai_dbanalyze.sh' as root on ducati.

Hello ramakoti,

Try the following.

When you use the command su - (user_name) you are change the variable for the next user_name.
Try the command without the "-"