@enable

Many device configuration tasks require a script to enter a privileged mode in order to execute the necessary device commands. On many devices, privileged mode is entered using the enable command. Typically, running the enable command on a device requires the user to enter a user name and/or password. For devices that implement this style of enable command, scripts can use the WhatsConfigured @enable command to easily enter privileged mode. The @enable command has no parameters, and is invoked as follows:

@enable

When the @enable command is executed, it does the following:

  1. It sends enable to the device followed by CommandTerminator.
  2. If it detects UserNamePrompt, it sends Settings.UserName to the device followed by CommandTerminator.
  3. If it detects PasswordPrompt, it sends Settings.PrivilegedPassword to the device followed by CommandTerminator. If Settings.PrivilegedPassword is empty, it uses Settings.Password instead.
  4. After entering the user name and password (if necessary), if @enable detects CommandPrompt, it assumes that enable was successful. Otherwise, it assumes that enable failed.

If at any time the device's output stalls for more than Settings.ReadTimeout seconds, it is assumed that something is wrong, and the script returns failure.

See Also

About WhatsConfigured command types

@login

Device commands

Low-level commands