Page 1 of 1

Sourcing environment files from sequence Execute Command stg

Posted: Tue Jul 21, 2009 8:14 pm
by sbass1
Hi,

I need to execute an external command in a sequence, where that external command needs a number of environment variables set.

From what I can deduce, the Execute Command stage executes the external command in the Bourne shell (sh). Since my environment files use the bash syntax, I need to also spawn a bash process.

My test sequence program has this command:

Code: Select all

/usr/bin/bash --login -c "env | sort"
This would spawn a bash process as a login shell, which should source my environment files, then echo the sorted environment to the DS log.

This command works fine in a Putty session; I login (bash), unset a few variables, invoke the Bourne shell (sh), then execute the above. I get the necessary environment variables.

When I run this in DS, I don't get the environment variables in the DS log, only the environment variables set in the DS Administrator console.

Finally, I ran this same process using "at now" to run it in true batch mode, just to ensure that bash --login sourced my login files.

I can get this to work by directly sourcing the login files from the Execute Command stage, i.e.

Code: Select all

/usr/bin/bash --login -c "~my_userid/.bash_profile ; env | sort"
but in my "real" program, this won't be portable across environments.

I did notice that $HOME=/ (which was unexpected) but $LOGNAME=<my userid>. Does DS launch its processes under some sort of proxy user, then sudo to the client login userid?

Thus

Code: Select all

/usr/bin/bash --login -c "~/.bash_profile ; env | sort"
i.e. without my userid specified, fails since it can't find //.bash_profile.

Any ideas?

Thanks,
Scott

Posted: Tue Jul 21, 2009 8:43 pm
by ray.wurlod
Maybe a Bourne shell script that does an su - username "command" where command executes your Bourne Again shell script. Might need a here script to supply the password value.

Posted: Tue Jul 21, 2009 8:46 pm
by sbass1
Thanks Ray. What I'm really looking for is a better understanding of how DS 7.x launches external commands under Unix.

If these details are doc'd somewhere, sorry, please point the direction. I searched on "Execute Command" before posting but got too many false hits.

Posted: Tue Jul 21, 2009 10:12 pm
by ray.wurlod
Have to do a "Sergeant Schultz" on that.

No idea where (if anywhere) these details are documented.

Hopefully Steve Totman or Stewart Hanna will pick up on this thread and be able to find/provide your answer.