beautypg.com

Piping output, Filtering output, Using closures and subcommands – Dell Acceleration Appliances for Databases User Manual

Page 18

background image

Piping Output

You can also pipe the text output of one command into another, using the piping symbol (“|”).
For example,

config:config | more

will page through the configuration one screen at a time.

A convenient pipe command is

grep

, which allows searching for values. For example:

luns -dt | grep some_volume

Filtering Output

The CLI enables a number of useful forms of filtering. Here are some sample expressions that can
guide your use:

• Get port objects and store them:

> p=(ports -o) // grab port objects and store

• Return a list of the modes of the ports:

> each $p {$1 mode} // get mode property

• Return a list of booleans indicating which ports are not management ports:

> each $p {$1 . mode . neq Management}

• Filter the ports, returning the ones that are management ports:

> each $p -w { $1 . mode . eq Management}

• Filter the ports, returning a list of the IDs of the ones that are management ports:

> each $p -w { $1 . mode . eq Management} {$1 id}

Using Closures and Subcommands

A closure is created by surrounding statement(s) with braces. This forms a function, which can be
used directly or assigned to a variable. Within a closure you can refer to any positional argument
by $n, where n is the number of the argument, starting with 1. $args refers to all the arguments
passed to the function.

admin@url> each (volumes) {volume:get $1}

vol1

vol2

...

You can use closures to create functions, by assigning the closure to a variable name. Once
created you can refer to the closure value by using the $ symbol, or can invoke the closure by
referring to the variable without the $ sign.

18