The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
prompt generic
    match /[\/a-zA-Z0-9._\[\]-]+ ?(?:\(config[^)]*\))? ?[#>] ?$/

prompt privileged
    match /# ?$/

prompt configure
    match /\(config[^)]*\)# ?$/

prompt user
    match /[Uu]sername: ?$/

prompt pass
    match /[Pp]assword: ?$/

# MACROS

macro begin_privileged
    send enable
    match user or pass or privileged

macro end_privileged
    send disable
    match generic

macro begin_configure
    send configure terminal
    match configure

macro end_configure
    send exit
    match privileged

macro disconnect
    send exit
    match generic

# macro completion
#     send ?

# for setting up automated reloading, requires argument N (minutes)
# note: if done as send-match sequence, then the 'has been modified' part
# is mandatory - but not all ios versions have that prompt...
# the follow...with construction on the other hand works with or without
# that step.
# note all lines that are matched against prompt or follow are STRIPPED from the response.
macro reload_in
    send reload in %s
#   match /System configuration has been modified. Save\? \[yes\/no\]:/
#   send no
    follow /System configuration has been modified. Save\? \[yes\/no\]:/ with  no\n
    match /Proceed with reload\? \[confirm\]/
    send ''
    match privileged

# no arguments. last match is pretty much a dud, the session will be gone.
macro reload
    send reload
    follow /System configuration has been modified. Save\? \[yes\/no\]:/ with  no\n
    match /Proceed with reload\? \[confirm\]/
    send ''
    match privileged