Skip to content

Tag: <commandstep> - Send A Device Intermediate Commands

Definition

The <commandstep> tag is used to send a command to the device but not wait for a success or failed tag to be matched.

It can be used to send commands in quick succession and you then wait for a final response from the last one before deciding if the command worked or not.

This tag has the following attributes:

Parameters

  • response_timeout (int): The response timeout (in seconds) is the time Osirium PAM waits after issuing a <commandstep> before it stops waiting for a response, and gives up. The default, when not specified, is 15 seconds.

  • shellprompt (str): This allows the templates <shellprompt> to be overwritten if the command being issued does not return with the standard prompt. See example below.

  • newline (str): Allows a specific new line character(s) to be defined to be sent at the end of the command. Can also be used to send just a new line character(s) with no element text defined.

  • Element Text (str): This is the command to be sent down to the device. This can contain one or more substitutions.

Example: Devices Asking Questions

This tag is useful for and should only be used for commands that might ask questions, like this::

1
2
3
4
5
6
7
device> add user
Username: kev
Password: ********
Home dir: /what/ever/
Confirm? yes
User 'kev' successfully added.
device>

In this simple example to add a user, the device asks questions after the command has been issued but before you get the final success message back from the device.

!! note This also uses the shellprompt attribute as the questions the device asks are not just the normal device prompt coming back.

So you would write the template like this:

1
2
3
4
5
6
7
8
<command shellprompt='Username:'>add user
   <commandstep shellprompt='Password:'>kev</commandstep>
   <commandstep shellprompt='Home dir:'>********</commandstep>
   <commandstep shellprompt='Confrim?'>/what/ever</commandstep>
   <commandstep>yes</commandstep>
   <sucesss type='ci_in' value='successfully added'/>
   <failed type='default' />
</command>

Remember here, that the shellprompt attribute on each commandstep is what we expect to get back AFTER sending the commandstep element text to the device.

If the device asks a question and you just need to hit enter to proceed or to accept a default, then the newline attribute can be used with no element text. Take the example device conversation above, if the 'Confirm?' step just wanted you to hit enter, then you could use:

1
2
3
4
5
6
7
8
<command shellprompt='Username:'>add user
<commandstep shellprompt='Password:'>kev</commandstep>
<commandstep shellprompt='Home dir:'>********</commandstep>
<commandstep shellprompt='Confirm?'>/what/ever</commandstep>
<commandstep newline='lf'/>
<sucesss type='ci_in' value='successfully added'/>
<failed type='default/>
</command>

The values of the newline attribute translate to:

Value Sent to device
crlf \r\n
cr \r
lf \n
none

Example: Long Running Task

By default, Osirium PAM waits 15 seconds for the device to reply with it's standard prompt.

As with the <command> tag if a command step needs to take longer than the default 15 seconds then the timeout can be extended like this:

1
<commandstep response_timeout='300'>iisreset</command>

This would override the default 15 second timeout and set the timeout to 300 seconds, or 5 minutes.

Parent Tags

Child Tags

  • None