The @connect
command is an alternative to @login
in cases where a script needs to precisely control the login process (e.g., in cases where @login
doesn't work for a particular device). The @connect
command connects to a device without trying to log in. After connecting to a device with @connect, if the device requires users to login, the script can control the login process precisely using the @write
and @read
commands, which are described later.
When calling @connect
, scripts can specify one or more patterns (i.e., strings or regular expressions) that specify the output the script expects to receive from the device when it connects. These patterns are used by @connect to detect the end of the device output. @connect
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. For example,
@connect "login as: ", "user name: "
When executed, @connect
connects to the device, and reads whatever output comes back from the device. If the output matches one of the specified patterns, the command succeeds. If the connection attempt fails entirely, or the output received from the device does not match any of the specified patterns, the command fails (as well as the entire script). As with any other command, a KEY can be specified to capture the command's output in the WhatsUp Gold database, although one would rarely want to store the output of an @connect
command.
If no patterns are specified (as shown below), @connect
connects to the device, and returns whatever output comes back from the device. In this case, the command succeeds as long as a connection is successfully established with the device.
@connect-more
Some devices return paged output that requires more
prompts when you initially connect to them. If a script needs to handle more
prompts during the connection process, it can use the @connect-more
command instead of @connect
. @connect-more
works just like @connect
, except that it handles more
prompts during the connection process, while @connect
does not. Specifically, if MorePrompt
is detected during the connection process, @connect-more
sends MoreResponse
to the device.
@connect-more "login as: ", "user name: "