Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

send Environment variable from context

Hi,
I am reading  csv files from different locations for my etl job,those files are having some common filepath. So common path is stored in an environment variable.Here i consider  'SOURCE_FOLDER' as a environment variable.
i am sending  a context parameter to my job as 
Folder_location=System.getenv("SOURCE_FOLDER")/filepath/
But i am unable to get the full file path while reading this variable.I am getting   System.getenv("SOURCE_FOLDER")/filepath/ while reading context variable . How can i get  environment variable value from context variable.  Thanks in advance.
Labels (2)
6 Replies
Anonymous
Not applicable
Author

Hi Mani,
context.Folder_location=System.getenv("SOURCE_FOLDER")/filepath/
Whether this is not returning you the value to context variable? What is the value of SOURCE_FOLDER in environment variable?
Thanks
Vaibhav
Anonymous
Not applicable
Author

SOURCE_FOLDER is a environment variable which having my file path like '/home/mani/Documents'.
 
While i am reading from my job i want to get the value in the environment variable like '/home/mani/Documents/filepath'. But i am getting only System.getenv("SOURCE_FOLDER")/filepath/.
Anonymous
Not applicable
Author

Can you pl show how you are calling... Actually it is a string concatenation operation, it should be written like
context.Folder_location=System.getenv("SOURCE_FOLDER")+"/filepath/"
Try printing the value using System.out.println(System.getenv("SOURCE_FOLDER"));
and see what value is printed on console... else there is a trouble in calling the environment variables.
Thanks
vaibhav
Anonymous
Not applicable
Author

Try printing the value using System.out.println(System.getenv("SOURCE_FOLDER"));   -- gives the correct results.

But i am reading all the context values from external file,By Prompting on context variable,  So that the context value i am reading in the job in like context.Folder_location only
 System.out.println(context.Folder_location);
I am getting result as System.getenv("SOURCE_FOLDER")+"/filepath/" 
But how to recognize System.getenv("SOURCE_FOLDER") -- value as a environment variable while sending from context. Because i think it is taking hole as a Object.
Anonymous
Not applicable
Author

I got you....
You are trying to send System.getenv("SOURCE_FOLDER") from property file / variable value...
Context can't recognize it, it will read it as a string... you have to use it in tJava or within the job component, you can get that value directly from environment variable, you need not set it in job level context variables.
Vaibhav
willm1
Creator
Creator

mani - could you please print the results of you context variable and your env variable - so we can separate out what each part is doing?