It's all about the answers!

Ask a question

How to define execution variables in the batch script


Leesen Padayachee (9959120) | asked Dec 07 '16, 4:52 a.m.
retagged Dec 16 '16, 1:00 a.m. by Minakshi Jaint (5113)
 Hi

When defining the execution variable before executing a command line script, how do would be define these variables in the batch file? I have read that these need to be passed as an environment variable to the batch script that calls the script(python in my case). It has to be in the form "qm_some variable". Please advise on how I would state this in the batch file.

Thanks,
Leesen

Accepted answer


permanent link
Dawn McMannama (515) | answered Dec 12 '16, 10:41 a.m.
edited Dec 12 '16, 5:26 p.m.
 Leesen,

You don't have to define the qm_ version of the variables.  RQM does that for you.

Not knowing what you are wanting to achieve, I am going to assume that you want to pass the execution variable values to the Python script.  You can pass the values as follows:

python c:\test\test.py %qm_var_age% %qm_var_color%

****************************
There is another option.  RQM also supplies a file that contains all the execution variables and their values.  The file can be accessed using the variable %qm_ExecutionVariablesFile%.  You can "echo" to see the contents.  For instance, when you open this file, it may contain
var_age = 15
var_color = pink

Notice the qm_ prefix is not used inside this file.

In this case you can use the following command.  Within the Python script, you can retrieve the values.  

python c:\test\test.py %qm_ExecutionVariablesFile%

****************************

You can also modify the values to be used in downstream test cases or add new execution variables and values to be used in downstream test cases by modifying the content of %qm_ExecutionVariablesFile%

We found this information at this URL and also through experimentation.
https://jazz.net/help-dev/clm/index.jsp?re=1&topic=/com.ibm.rational.test.qm.doc/topics/qm/Test-Artifacts-Workflows-State-Group.html?resultof=%22workflow%22%20&scope=null

Leesen Padayachee selected this answer as the correct answer

Comments
1
Leesen Padayachee commented Dec 13 '16, 3:51 a.m.

 Dawn, thank you so much for your assistance. I managed to pass the variables to the .py script!

One other answer



permanent link
Dawn McMannama (515) | answered Dec 08 '16, 12:36 p.m.
For this example, there are 2 execution variables defined.  They can be defined in the test suite, test case, and/or test script:
var_age = 15
var_color = red

When the command line script (.cmd or .bat) is invoked, the script accesses the variables as follows:
%qm_var_age%
%qm_var_color%


I believe this will also work for project variables, but the value is an enum rather than a string value.

Comments
Leesen Padayachee commented Dec 09 '16, 1:36 a.m. | edited Feb 16 '17, 1:05 a.m.

  Hi Dawn


Thank you for the response.

How would %qm_var_age% be defined in the batch file? This is an example of my batch file:

@echo off
python c:\test\test.py %*

echo LOGFILE=C:/pyAutomationFramework/Data/Scripts/RunScripts_20150319_110347_72/logfile.html >> %qm_AttachmentsFile%

As you can see my log file attachment is defined with an echo statement.
Can I just state it as : 
%qm_var_age%
%qm_var_color%


and then create 2 input variable called " var_age" and "var_color" in my python script?

Thanks for your help!

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.