@read

The @read command can be used by scripts to read the output coming back from the device. Typically, a call to @read will immediately follow a call to @write. When calling @read, scripts can specify one or more patterns (i.e., strings or regular expressions) to help @read detect the end of the device output. @read will assume that device output is complete when either: the output matches one of the specified patterns, or no new output has been received from the device for Settings.ReadTimeout seconds. Often, the output will end with CommandPrompt, so "@read $(CommandPrompt)" is a common way to call @read. If desired, the output received from the device can be stored in the WhatsUp Gold database, as shown below:

@write "show run"

@write $(CommandTerminator)

[running-config, trim-end-lines = 1] @read $(CommandPrompt)

When executed, @read will read whatever output comes back from the device. If the output matches one of the specified patterns, the command succeeds. If the output received from the device does not match one of the specified patterns, the command fails (as well as the entire script).

If no patterns are specified (as shown below), @read will return whatever output comes back from the device. In this case, the command will succeed as long as the connection to the device is still open.

@read-more

Some devices return paged output that requires more prompts. If a script needs to handle more prompts during a read operation, it can use the @read-more command instead of @read. @read-more works just like @read, except that it handles more prompts during the reading process, while @read does not. Specifically, if MorePrompt is detected during the reading process, @read-more will send MoreResponse to the device.

See Also

Low-level commands

@connect

@write