Skip to the content.

Tutorial: Execute script using a parameter list

This page guide you through creating executing a script while defining a list of parameters to use at the start. We will make use of the option paramlist which is part of the script launcher. In that way it will be possible to increase the reusability factor of the automation design.

In this tutorial we will create a script helloparameter that will make use of a parameter list that is provided when executing the script.

Pre-requisites

Create script

First, we will create the script that makes use of a parameter in its action design. Parameters are defined using the # symbol before and after its name: #variable#. you can get more information about this as part of the design page.

---
type: "script"
data:
  name: "helloparameter"
  description: "Hello Parameter Tutorial Script"
  parameters: []
  actions:
  - number: 1
    type: "fwk.outputMessage"
    name: "outputParameter"
    description: "View the parameter value"
    component: ""
    condition: ""
    iteration: ""
    errorExpected: "N"
    errorStop: "N"
    parameters:
    - name: "message"
      value : "my first parameter: #param1#"
    - name: "onScreen"
      value : "Y"

Have a look at the action that we have defined in the above script:

Load and execute the script

Now, load the configuration into the configuration repository and execute the script.

Linux/Mac

./iesi-launch.sh -script helloparameter -env tutorial

Windows

./iesi-launch.cmd -script helloparameter -env tutorial

You will notice the following output:

2019-04-05 07:39:44,806 INFO  [iesi] - action.message=my first parameter: 

The fixed string is displayed but no value is displayed for the parameter. We did not pass any value to the execution. This can be done through the -paramlist <arg> option of the command. Let’s run the following command:

Linux/Mac

./iesi-launch.sh -script helloparameter -env tutorial -paramlist param1=value1

Windows

./iesi-launch.cmd -script helloparameter -env tutorial -paramlist param1=value1

Now, the output reflects the value of the parameter that we provided:

2019-04-05 07:43:26,360 INFO  [iesi] - action.message=my first parameter: value1

Update the script and add an additional parameter

In order to add additional parameters the same approach is repeated. We can provide additional key=value pairs to the -paramlist option by separating pair using ,: -paramlist param1=value1,param2=value2,...

Update the script to display also a second parameter:

    - name: "message"
      value : "my first parameter: #param1# and my second parameter: #param2#"

Load the configuration into the configuration repository and execute the script.

Linux/Mac

bin/iesi-launch.sh -script helloparameter -env tutorial -paramlist param1=value1,param2=value2

Windows

bin/iesi-launch.cmd -script helloparameter -env tutorial -paramlist param1=value1,param2=value2

This leads to the following output on the screen:

2019-04-05 07:49:35,663 INFO  [iesi] - action.message=my first parameter: value1 and my second parameter: value2

Recap

We have now created a script that makes use of several parameters and executed it on the tutorial environment. We can now start making use of parameterized actions to create better reusable automation designs.