Sourcing environment files from sequence Execute Command stg

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
sbass1
Premium Member
Premium Member
Posts: 211
Joined: Wed Jan 28, 2009 9:00 pm
Location: Sydney, Australia

Sourcing environment files from sequence Execute Command stg

Post 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
Last edited by sbass1 on Wed Jul 22, 2009 6:15 pm, edited 1 time in total.
Some people are the Michael Jordan's of Datastage. I'm more like Muggsy Bogues :-)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sbass1
Premium Member
Premium Member
Posts: 211
Joined: Wed Jan 28, 2009 9:00 pm
Location: Sydney, Australia

Post 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.
Some people are the Michael Jordan's of Datastage. I'm more like Muggsy Bogues :-)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply