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)

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.


Accepted answer

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

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\ %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\ %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.

Leesen Padayachee selected this answer as the correct answer

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:

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

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\ %*

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 : 

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.