Pass UNIX environment variable to DataStage jobs
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 12
- Joined: Thu Apr 27, 2006 3:17 pm
- Location: Bay Area
Pass UNIX environment variable to DataStage jobs
I want to pass UNIX environment variables to datastage job. IN the job property, I entered the UNIX envrionment variable's name $SCHEMA_NAME, this is a unix environment variable with a value USA. In the parameter's default value, I entered $ENV. When I run the job, I expect that the parameter will get USA as it's default value, instead, it shows $ENV. It did not resolve the $ENV to get the value from UNIX environment. Did I do something wrong? How do I set it up so that it will get the value from UNIX environment when it is $ENV?
-
- Premium Member
- Posts: 497
- Joined: Sun Dec 17, 2006 11:52 pm
- Location: Kolkata
- Contact:
Re: Pass UNIX environment variable to DataStage jobs
In the parameter's default value put $PROJDEF.
More to it than that. You first need to define it in the Project as a user-defined environment variable using the Administrator and that sounds like the step you missed. There you would set its value to $ENV which means it will take the current value from the job's environment.
Then in the job, add the variable from the picklist and change what it defaults to to $PROJDEF as suggested - that will get you the Project Default which in your case is $ENV.
In some cases, like say in a Transformer, you can simply fetch it from the environment using (off the top of my head) the GetEnvironment() function. Note that when you pass it the name of the variable, do not include the dollar sign. Best to do this in the Initial Value of a Stage Variable and then reference it there, making sure the derivation is left empty, that gets the value one time when the job starts and then leaves it static over the course of the job. FYI.
Then in the job, add the variable from the picklist and change what it defaults to to $PROJDEF as suggested - that will get you the Project Default which in your case is $ENV.
In some cases, like say in a Transformer, you can simply fetch it from the environment using (off the top of my head) the GetEnvironment() function. Note that when you pass it the name of the variable, do not include the dollar sign. Best to do this in the Initial Value of a Stage Variable and then reference it there, making sure the derivation is left empty, that gets the value one time when the job starts and then leaves it static over the course of the job. FYI.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 12
- Joined: Thu Apr 27, 2006 3:17 pm
- Location: Bay Area
I followed what you said here, added SCHEMA_NAME environment variable in Administrator and set its value as $ENV. Then in the DS job, I added the variable by picking it up from the "Add Environment Variable...". Then I changed its default $ENV to $PROJDEF. Compile and run the job. I wrote the value of this parameter out and it is $ENV, it did not get the UNIX environmental value USA. Why it could not see the UNIX environmental value? Did I miss something? Do we need to do some setup in the DS project level?
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Premium Member
- Posts: 12
- Joined: Thu Apr 27, 2006 3:17 pm
- Location: Bay Area
-
- Premium Member
- Posts: 12
- Joined: Thu Apr 27, 2006 3:17 pm
- Location: Bay Area
-
- Premium Member
- Posts: 12
- Joined: Thu Apr 27, 2006 3:17 pm
- Location: Bay Area
Then it's not in the right environment, the one the job uses when it runs. Set it in dsenv instead. That or explicitly set the vaule in the Project to what you need it to be (this rather than $ENV) but still stick with $PROJDEF in the job.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Use a before-job subroutine in any job - even a test job - to invoke a command like echo $SCHEMA_NAME via the ExecSH subroutine.Hongqing Tang wrote:I am not sure. How do you check that? How do you set it up in the shell if they are not there? Thanks so much in advance.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 12
- Joined: Thu Apr 27, 2006 3:17 pm
- Location: Bay Area
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
That suggests that SCHEMA_NAME is not defined in the executing user's environment. Try setting SCHEMA_NAME in the dsenv script, as earlier advised. Or in the .profile file of the executing user, if you must.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.