Follow

How do I pass variables between scripts? Can you provide a good example?

KB#:  KKB000677

QUESTION

How do I pass variables between scripts? Can you provide a good example?

 

ANSWER

We define the parent script as the script which contains the Execute Script or Schedule Script action which causes a subsequent script to be run, and the child script as the script which is run as a result.

Any variable defined in a parent script is available to the child script BUT not the other way around.

Import the following example for details:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<folderDef0 >
<scriptDef >
<scriptIf ifFunc="1" fp1="" fp2="" fp3="" ifTest="0" testVal="" script description="" />
<scriptThenElse te stepNum="1" teFunc="26" fp1="10" fp2="" fp3="ktemp" os contOnFail="0" />
<scriptThenElse te stepNum="2" teFunc="26" fp1="5" fp2="" fp3="utemp" os contOnFail="0" />
<scriptThenElse te stepNum="3" teFunc="26" fp1="6" fp2="" fp3="agent" os contOnFail="0" />
<scriptThenElse te stepNum="4" teFunc="1" fp1="5722226" fp2="" fp3="0" os contOnFail="0" />
</scriptDef>
<scriptDef >
<scriptIf ifFunc="1" fp1="" fp2="" fp3="" ifTest="0" testVal="" script description="" />
<scriptThenElse te stepNum="1" teFunc="12" fp1="#ktemp# - #utemp# - #agent#" fp2="0" fp3="" os contOnFail="0" />
</scriptDef>
</folderDef0>

 

MORE INFORMATION

Contrast this with the following set of scripts, which defines the variables in the child script. The parent is not able to access these, and the script fails.

<?xml version="1.0" encoding="ISO-8859-1" ?>
<folderDef0 >
<scriptDef >
<scriptIf ifFunc="1" fp1="" fp2="" fp3="" ifTest="0" testVal="" script description="" />
<scriptThenElse te stepNum="1" teFunc="26" fp1="10" fp2="" fp3="ktemp" os contOnFail="0" />
<scriptThenElse te stepNum="2" teFunc="26" fp1="5" fp2="" fp3="utemp" os contOnFail="0" />
<scriptThenElse te stepNum="3" teFunc="26" fp1="6" fp2="" fp3="agent" os contOnFail="0" />
</scriptDef>
<scriptDef >
<scriptIf ifFunc="1" fp1="" fp2="" fp3="" ifTest="0" testVal="" script description="" />
<scriptThenElse te stepNum="1" teFunc="1" fp1="80887573" fp2="" fp3="0" os contOnFail="0" />
<scriptThenElse te stepNum="2" teFunc="12" fp1="#ktemp# - #utemp# - #agent#" fp2="0" fp3="" os contOnFail="0" />
</scriptDef>
</folderDef0>

 

APPLIES TO

Script tab
Script variables

 

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.