1753951 Members
7610 Online
108811 Solutions
New Discussion

Interactive script

 
SOLVED
Go to solution
Chuv
Occasional Contributor

Interactive script

Hello , 

I would like to know if it was possible to create interactive scripts with iMC. For example, when I run the script, it asks me the hostname, the IP address ... of the switch that I have to write.

Is it possible ? 

 

Thanks.

3 REPLIES 3
jguse
HPE Pro
Solution

Re: Interactive script

Hello,

Indeed, iMC supports interactive CLI Scripts. These will be run via Telnet/SSH on the devices of your choosing, and the commands they run can contain variables, which you would fill out during deployment of the script.

CLI Scripts can be created via Service > Configuration Center > Configuration Templates. Create a new CLI script and replace the parts of the commands where you would like to use variables with ${variable-name} such as the following example for ProCurve/ArubaOS:

 

configure

vlan ${vlan-id}

ip address ${vlan-ip-address}

name ${vlan-name}

exit

write memory

 

When you deploy the script, it will prompt you to fill out these variables, which can be filled out with separate or combined values for individual or multiple devices.

Hope that helps. Let me know if you have any further questions.

Best regards,
Justin

Working @ HPE
Accept or Kudo
Chuv
Occasional Contributor

Re: Interactive script

Thank you for your reply.

I have another question. Is it possible to make loops (when, for, if)?

Thank you !

jguse
HPE Pro

Re: Interactive script

Hello,

Not exactly - but you can use the feature "Response prompt" feature in the scripts to essentially expect certain output (success or error output), and have the script act differently depending on which success or error output is received.

Here is a description of response prompt from the iMC in-context help:

  • The Successful Prompt means the command run successfully and continuing next command only if the device's echo information matches the prompt. The Error Prompt means the command run failed and exit when the device's echo information matches the error prompt. In the Advanced Mode, the default mode is Successful Prompt, the "!" means Error Prompt. For example, the string "dis acl number ^|^ acl" indicates a successful prompt of "acl", whereas the string "dis acl number ^|^ !acl" indicates an error prompt of "acl".
  • To specify only a prompt for a line, input the prompt content and ^|^. For example [device]^|^. To specify only command for a line, input the content of the command directly.

There's also a detailed tip when creating a CLI Script:

HPE Intelligent Management Center Variables.png

So response prompt is essentially like creating an "if" statement. The programming equivalent of "while"/"for" shouldn't be needed, as you can simply deploy the CLI script on many devices at once, and either adjust the variables on a per-device basis or run the exact same commands on all devices.

Hope that helps.

Best regards,
Justin

Working @ HPE
Accept or Kudo