Problem in getting environment variable in routines...

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

kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Problem in getting environment variable in routines...

Post by kaps »

Hi

I am trying to use environment variables in Routine(Transform Function).
I got some idea from this forum as to use echo statements to get the env values and I use modified UtilityHashLookup Routine to read. It works fine If I hard code the path of hash file like following

HashTable=/dir/dir/dir/Translation_hsf

but it gives me "Table Not Found" error If I do the follwoing...

HashTable = HashFilePath:"/Translation_hsf"

where HashFilePath has the actual path derived from the echo command which works fine.

Does anyone know the reason ?

Thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Could you post your code where you are getting the results of the ECHO command? Perhaps there are extraneous characters in that returned string that you aren't filtering out.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You sure your not sending in any spaces. Try

Code: Select all

HashTable = TRIM(HashFilePath):'/Translation_hsf'
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I'm thinking not of spaces but of an extra @FM (which is what crlf's get converted to when calling shell commands)
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Ahh....The field markers. Then how about the OP tries this

Code: Select all

HashTable = Field(HashFilePath1,@FM,1):'/Translation_hsf' 
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
vsi
Premium Member
Premium Member
Posts: 507
Joined: Wed Mar 15, 2006 1:44 pm

Post by vsi »

Thanks for the response.

Arnd - This is the code I am using to get the env variables...

Call DSExecute("UNIX","echo $prm_project_path$prm_path_common",UnixOutput,SystemReturnCode)
HashFilePath = Trim(UnixOutput)

DSGuru - I am getting the same error when I tried your second mathod.\

Thanks
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

Thanks for the response.

Arnd - This is the code I am using to get the env variables...

Call DSExecute("UNIX","echo $prm_project_path$prm_path_common",UnixOutput,SystemReturnCode)
HashFilePath = Trim(UnixOutput)

DSGuru - I am getting the same error when I tried your second mathod.\

Thanks
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

kaps wrote:Thanks for the response.

Arnd - This is the code I am using to get the env variables...

Call DSExecute("UNIX","echo $prm_project_path$prm_path_common",UnixOutput,SystemReturnCode)
HashFilePath = Trim(UnixOutput)

DSGuru - I am getting the same error when I tried your second mathod.\

Thanks
Why is the same thing being posted twice under different member_id's?
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

That is because your routine says something else and the DSExecute() statement reveals something else. Tell me this, what are the values of $prm_project_path and $prm_path_common?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

Value of $prm_project_path is /datastage/dev/srcdev/ and value of $prm_path_common is common/. It's all just directories in AIX.

So value of the the HashFilePath is /datastage/dev/srcdev/common/

Thanks
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Ok. Try one of these. They should work

Code: Select all

Call DSExecute("UNIX","echo $prm_project_path$prm_path_common",UnixOutput,SystemReturnCode) 
HashFilePath = Field(UnixOutput, @FM,1)
OR

Code: Select all

Call DSExecute("UNIX","echo $prm_project_path$prm_path_common",UnixOutput,SystemReturnCode) 
HashFilePath = UnixOutput<1>
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

I don't know what's going on...The code which worked few hours before is not working now...

Even this small piece of code is not working now...I just have the following code in a test routine...which does not give me the output...

Call DSExecute("UNIX","echo $prm_project_path",UnixOutput,SystemReturnCode)

Ans = Trim(UnixOutput)

Thanks
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Log onto your unix server and run the same command. Does it spit out the value?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

It won't sipt out the value as the variable is DataStage environment variable. So Unix will recognize only If I run from DataStage.
Is my understanding correct ?

Thanks
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

NO. It wont. Thats what i wanted to find out. If it does'nt work from command line, it wont work from DSExecute() either.
Go to your unix prompt, type env. What ever variables you see there, only they can be called.
I wonder how it was working before.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply