Response file variables

Parameterized variables in response files can improve the enterprise deployment experience for customers. We can adapt the response files for different contexts by defining variables in response files. For example, if we have multiple response files that do similar things on different operating systems, we can adapt one response file to be used on different operating systems using variables. We can use predefined variables and we can also define custom variables.


Predefined variables

Predefined variables contain a colon in their name.

Predefined variable Description Possible value
platform:os The operating system. See Command-line arguments for the pucl command for a list of values.
platform:arch The architecture of the system, regardless of whether Installation Manager is running as a 32-bit or 64-bit application. See Command-line arguments for the pucl command for a list of values.
platform:nl The string name of the current locale, from the -nl option or the default locale of the system. See supported languages for a list of language strings.
hostName:fullHostName The full host name of the machine, which is computed by calling InetAddress.getLocalHost().getCanonicalHostName(). machine1.lab.ibm.com
hostName:shortHostName The short host name of the machine. machine1
hostName:domainName The domain name of the machine. lab.ibm.com
environment:[name] The value of the name environment variable.  
system:[key] The value of the key system property.  
user:name The user's login name.  
user:home The full path name of the user's home location.  
specialFolder:PROGRAM_FILES The path to the program files directory of a windows computer.  


Custom variables

Define custom variable in the <variable></variable> section of the response file.

Use the following code to declare a variable in a response file:

<variable name='name1' />

To add a default value, add a value parameter:

<variable name='name1' value='defaultValue1' />

When we use a response file that defines variables that do not have default values, we must define the value on the command line. Otherwise, an error is generated. To set a value for a variable that does not have a default value or to override a default value for a variable, use the -variables command-line command. Values that you set on the command-line override values that are set in the response file. Custom variables must be declared before they are used or set on the command line. We cannot declare a variable on the command line.

Use the following command to define or override the value for the name1 variable on the command line:

imcl input install.xml -variables name1=value1

To use variables in your response file, put the variable name within this form: ${varName}

Use the following code to assign the value of a user:name predefined variable to name1 custom variable:

<variable name='name1' value='${user:name}'/>


IF statements

You can change the variable values using IF statements that apply to the values of predefined variables or custom variables.

In the following code, the name1 variable has the default value of defaultValue1. If the value of name2 variable equals foo, then the value of name1 variable is set to defaultValue2.

<variable name='name1' value='defaultValue1'>
  <if name='name2' equals='foo' value='defaultValue2'/>
</variable>

The following code shows how to use predefined variables in IF statements. The name1 variable has the default value of defaultValue1. If the running platform value equals win32, then the value of name1 variable is set to defaultValue2.

<variable name='name1' value='defaultValue1'/>
  <if name='platform:os' equals='win32' value='defaultValue2'/>
</variable>

IF statements can also be nested. In the following code, the name1 variable has the default value of defaultValue1. If the name2 variable equals value foo, then the value of name1 variable is set to defaultValue2 unless one of its nested conditions is true. If the name3 variable equals value a, then the value of name1 variable is set to defaultValue3. If the name4 variable equals a, then the value of the name1 variable is set to defaultValue4.

<variable name='name1' value='defaultValue1'>
  <if name='name2' equals='foo' value='defaultValue2'>
    <if name='name3' equals='a' value='defaultValue3' />
    <if name='name4' equals='b' value='defaultValue4' />
  </if>
</variable>


Example 1

This example is a response file fragment that defines two variables: languages and installDir. The ${installDir} variable has different values depending on the OS and architecture.

<agent-input>
  <variables>
    <variable name='languages' value='en,fr'/>
    <variable name='installDir' value='/opt/foo'>
      <if name='platform:os' equals='win32' value='C:\Foo'/>
        <if name='platform:os' equals='linux'>
        <if name='platform:arch' equals='x86' value='/opt/foo_x86'/>
        <if name='platform:arch' equals='ppc' value='/opt/foo_ppc'/>
      </if>
  </variable>
</variables>
<profile id='my_profile' installLocation='${installDir}'>
  <data key='cic.selector.nl' value='${languages}'/>
</profile>
...

This response file can be used as-is, or we can override the variables the command line:

imcl input install.xml -variables languages=en,,es

In the syntax for defining variables, the single comma (",") is for defining multiple variables:

-variables var1=val1,var2=val2,var3=val3

If the variable itself has a comma (","), use two commas (",,"):

-variables var1=val1,,val2,,val3,var2=val4,var3=val5


Example 2

In this example, the installer defines the role on the command line and determines the features. If the role variable is not specified on the command line, the installer encounters an error because no default value is set.

<variables>
  <variable name='role'/>
  <variable name='features'>
    <if name='role' equals='developer' value='feature1,feature3'/>
    <if name='role' equals='architect' value='feature2,feature3'/>
  </variable>
</variables>
<install>
  <offering id='my.offering.id' features='${features}'/>
</install>

This response file cannot be used as-is. The role variable must be defined on the command line, and the role must be set as developer or architect:

imcl input install.xml -variables role=developer

Related information:

  • Command-line arguments for the pucl command
    Home