Hitachi

JP1 Version 12 JP1/Automatic Operation Service Template Developer's Guide 


6.4.7 Specifying commands in the CLI Command text box

The information you can enter in the CLI Command text box depends on the option specified for Execution Mode and whether you choose to specify the value of an input property as an argument of the command you are executing.

In the CLI Command text box, you can specify characters other than control characters (\u0000 to \u001F and \u007F to \u009F). However, JP1/AO does not check the validity of the command entered in the CLI Command text box. Therefore, enter a command for which validation has been completed.

Note that special characters specified in the CLI Command text box, such as those used to indicate environment variables, will not be escaped. However, depending on the selection of Operating System, the following characters are automatically escaped when the values of mapped input properties are passed to the command line:

When mapping an input property as a command line argument, enclose the value of the argument in double quotation marks (for example, "?dna_property-key-of-plug-in-property?"). When executing a PowerShell script, you can enclose the value in double or single quotation marks.

If Operating System is Windows and the value of an input property contains a double-quotation mark, an error will occur when the plug-in is executed.

When Script is specified for Execution Method

Create the script to be executed on the target device, and enter the command that calls the script in the CLI Command text box. If the script is a single file, specify the file name. If the script is a zip archive containing multiple files, specify a relative path whose current directory is the location where the archive will be extracted.

The script is copied to a temporary folder under the folder specified in Execution Directory.

If Operating System is AIX, HP-UX, Linux, or Solaris, the command line is automatically prefixed with ./ when the command is executed. You do not need to manually add the prefix. If you specify ./ in the command line, the script file appears after ././ but still works normally. Special characters, such as those used to indicate environment variables in the command line, are not escaped.

The following shows how to enter information in the CLI Command text box when the Script option is specified for Execution Method:

Example of specifying information in the CLI Command text box

cmd.exe /q /c "AAA.bat bbb ccc"

Example of script file (AAA.bat) contents

[Figure]

If the value in Operating System is Windows, the command is converted to a batch file and executed on the operation target device. For this reason, the results of the command might differ from those of the same command executed at the command prompt.

When CLI Command is specified for Execution Method

Enter the command to be executed on the operation target device directly in the CLI Command text box. You do not need to create a script.

The following shows how to enter information in the CLI Command text box when the CLI Command option is specified for Execution Method:

Example of specifying information in the CLI Command text box

zzz.exe aaa bbb

When specifying input property values as command arguments

To specify the value of an input property in an argument of a command, specify ?dna_property-key-of-plug-in-property? in the CLI Command text box.

Example of specifying information in the CLI Command text box

scriptA.sh -xx ?dna_input01? -yy ?dna_input02?

In this example, ?dna_input01? is replaced with the value of the plug-in property input01, and ?dna_input02? is replaced with the value of the plug-in property input02.

When specifying a non-standard script

JP1/AO executes scripts using cmd.exe when the operation target device is running Windows, and the user's login shell when the device is running UNIX. If you want to run a non-standard script, you need to define the instructions required to run the executable file that implements the script.

The following shows an example of running a PowerShell script from the command prompt and establishing a connection with vCenter:

Example of specifying information in the CLI Command text box
powershell -executionPolicy RemoteSigned -command ".\vsphereConnectChallenge.ps1 '?dna_vCenterServerName?' '?dna_userName?' '?dna_password?' '?dna_portNumber?' '?dna_protocol?'; exit $LASTEXITCODE" 2>&1
  • PowerShell cannot execute scripts by default. By specifying powershell -executionPolicy RemoteSigned in the command line, you can execute a local PowerShell script on an operation target device of JP1/AO.

  • Here, ?dna_property-key? is a variable replaced with the value of a property. Enclose ?dna_property-key? with double or single-quotation marks.#

    This allows the properties specified in the CLI Command text box to be passed to the shell even if the property has a null value.

    # If you enclose a property with double-quotation marks (") in PowerShell and that property has a null value, PowerShell skips the property. If you enclose it in single-quotation marks ('), the property is interpreted as a null value and not skipped. By avoiding double-quotation marks ("), you can ensure that the script is executed as originally defined in terms of the order and content of arguments.