How to run cmds after changing to a new env (shell) in a shell script

Hi,

I am using HP-UNIX.

I have a requirement as below

I have to change env twice like:

cadenv <env>
cadenv <env>
ccm start -d /dbpath
ccm tar -xvf *.tar
ccm rcv ....
mv *.tar BACKUP

but after I do the first cadenv <env> , I am unable to execute any of the later commands .

I have tried using /bin/sh -c "cmd"

but it does not seem to work. I have not sepreated these cmds by ; though. They are still seperated by newline. they look as below:

cadenv <env>
cadenv <env>
/bin/sh -c "ccm start -d /dbpath"
/bin/sh -c "ccm tar -xvf *.tar"
/bin/sh -c "ccm rcv ...."
/bin/sh -c "mv *.tar BACKUP"

can someone please help?

thanks,
Charlei

Not sure what cadenv and ccm are, but have your tried executing your commands using full paths?

sh -c "/path/to/ccm ..."

Perhaps the new environment is losing your $PATH variable?

Hello Stanley
cadenv executes a script that takes it to a different environment (with its own set of variable. when I do a id command, it has an extra context value in it..)

ccm is the command to start CM syerngy from the commandline.

I have also tried the below:

.
.
(exec cadenv..; exec cadenv..;exec bsh -q qname;)
ccm start -d /dbpath
..

this worked once, but does not work now...

Tried as suggested by you, but does not work..

regards,
Charlei

script should read:

.
.
(exec cadenv..; exec cadenv..;exec bsh -q qname )
ccm start -d /dbpath
..

The script cadenv is used to set environment variables? Run the cadenv script in the current shell (source):

. ./cadenv <env>

Regards

Hi Franklin

I tried this but I get the error below

./cadenv : not found

regards,
Iniyan

Try:

. cadenv

or use the full path:

. /path/to/cadenv

Regards