[resolved] Passing variable (context) value from the command line

One Star

[resolved] Passing variable (context) value from the command line

Is it possible to define variable context value from the command line (by the script generated by the export job in TOS).
For example
java -Xms256M -Xmx1024M -cp ../lib/jtds-1.2.jar;../lib/systemRoutines.jar;../lib/userRoutines.jar;.;myjob.jar;../lib; myproject.myjob.MYJOB --context=PROD
--myvariable='TEST'

Accepted Solutions
One Star

Re: [resolved] Passing variable (context) value from the command line

It's ok, it works.
I've passed a parameter to my .bat file an set "--context_param file=%1".

All Replies
One Star

Re: [resolved] Passing variable (context) value from the command line

hello
yes it is.
Here is an example (with Perl, but Java should be OK) I inserted in a bat file:
"perl" -I"lib" "NPLMATCH%1.job_Jnplmatch.pl" --context=Default --context_param rootDir=%%1 --context_param user=%%2 --context_param password=%%3 --context_param mode=%%4 --context_param backup=%%5 overloads $_context{rootDir} and $_context{user} and $_context{password} and $_context{mode} and $_context{backup}
Employee

Re: [resolved] Passing variable (context) value from the command line

Hello,
I confirm : it's the same in Java.
One Star

Re: [resolved] Passing variable (context) value from the command line

Very good and thanks for your answers.
It would be a good idea to add all these options in the documentation, I don't find them.
One Star

Re: [resolved] Passing variable (context) value from the command line

What is exactly overloads in your example ?
Is it a reserved keywords or just a data ?
Employee

Re: [resolved] Passing variable (context) value from the command line

Another example in java:
--context_param:params_file=/home/stephane/blog/articleContexts/execution/params_prod.csv

The ':' between context_param and params_file is due to a bug in 2.2.1 (don't know if we still have the bug)
Note that any key can be used instead of ':'
One Star

Re: [resolved] Passing variable (context) value from the command line

Hi all!
I have a main job with subjobs (in java with TOS 2.4.1).
One of my subjob read a file.
I want my batch to take in its parameters in the command line the path of this file.
I have in the context of my subjob a context variable for this file and in my command line I've added --context_param file="c:\toto.txt".
But it doesn't work.
Any ideas?
One Star

Re: [resolved] Passing variable (context) value from the command line

Java uses / instead of \
\ is a string escape character which can produce strange effects.
Can you try with --context_param file="c:/toto.txt" and see if it works?
One Star

Re: [resolved] Passing variable (context) value from the command line

Java uses / instead of \
\ is a string escape character which can produce strange effects.
Can you try with --context_param file="c:/toto.txt" and see if it works?

Thanks but it's not the problem.
The context param is not loaded, I've try with --context_param file="toto.txt" ...
One Star

Re: [resolved] Passing variable (context) value from the command line

Hi all!
I have a main job with subjobs (in java with TOS 2.4.1).
One of my subjob read a file.
I want my batch to take in its parameters in the command line the path of this file.
I have in the context of my subjob a context variable for this file and in my command line I've added --context_param file="c:\toto.txt".
But it doesn't work.
Any ideas?

Help!!
Smiley Happy
One Star

Re: [resolved] Passing variable (context) value from the command line

It's ok, it works.
I've passed a parameter to my .bat file an set "--context_param file=%1".
Two Stars

Re: [resolved] Passing variable (context) value from the command line

Hi Passing the value as a parameter from command line is ok and depicted by many one but how to receive the passed value inside the talend job is pending. Can any one please let us know how to receive the value inside.