Net::C...sebook(3pm)

πŸ“¦
version 2.400002 Β· 6 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay bestie, welcome to Net::C...sebook(3pm) β€” which is the manual page for Net::CLI::Interact::Manual::Phrasebook, aka the big glittery list of all the CLIs this module already knows how to talk to. it's from the User Contributed Perl Documentation set, and no cap, it is so useful. πŸ¦‹


✨ INTRODUCTION ✨

so the phrasebook that ships with the module? it already supports a whole bunch of network device CLIs, and so many of them were contributed by users of the module. like, real ones. if you go and set up a new CLI dictionary, please please please consider contributing it back?? the group chat would love that. 🫢

the spec for how a phrasebook is even structured lives over in Net::CLI::Interact::Phrasebook β€” go read that if you wanna know the rules.

for every supported CLI there's a name, and you must pass that name in the "personality" option to Net::CLI::Interact's new() method. and get this β€” that name is literally the same as the directory containing the phrasebook file. iconic, honestly. πŸ’…

once you've done that, you can call the included Macros, and the module will use the included Prompt to match whatever state your CLI is currently in. more deets live in the Tutorial and the Cookbook. πŸŽ€


πŸ‘‘ PERSONALITIES πŸ‘‘

if you want the full tea, go look at the files themselves at this link: <https://github.com/ollyg/Net-CLI-Interact/tree/master/share/phrasebook>

  • ASA πŸ’œ
  • Avaya πŸ’œ
  • Bash πŸ’œ
  • CatOS πŸ’œ
  • Cisco (generic) πŸ’œ
  • Csh πŸ’œ
  • ExtremeOS πŸ’œ
  • F5 πŸ’œ
  • Fortinet πŸ’œ
  • Foundry / Brocade πŸ’œ
before you connect to the device you probably want to set the output separator to be this, bestie:
$nci->transport->ors("\r\n");

and if you're a user of Net::Appliance::Session, this should be:

$session_obj->nci->transport->ors("\r\n");
  • FWSM πŸ’œ
  • FWSM 3 πŸ’œ
  • HP πŸ’œ
  • IOS πŸ’œ
  • JunOS πŸ’œ
  • Mikrotik πŸ’œ
  • Nortel πŸ’œ
  • OVMCLI πŸ’œ
  • PIXOS πŸ’œ
  • PIXOS 7 πŸ’œ
  • Qnap πŸ’œ
  • RedBack πŸ’œ
  • ScreenOS πŸ’œ
  • WLC πŸ’œ
  • Zyxel πŸ’œ

🌈 SUPPORTING A NEW DEVICE 🌈

so you wanna support a new device? especially for the Net::Appliance::Session module? okay slay, here's the thing: there's a basic set of prompts and macros you must create. no skipping. 🧚

πŸ’« Required Prompts πŸ’«

with SSH, you don't need a "user" prompt at all β€” ssh said "not my problem". but for other transports you should include a prompt named "user" which matches the "Username:" prompt that the device throws at you.

# example only!
prompt user
    match /[Uu]sername/

with all transports though, you absolutely must provide a "pass" prompt, and it matches the "password:" prompt the device presents. mandatory. periodt.

# example only!
prompt pass
    match /[Pp]assword: ?$/

and the last essential prompt is, of course, just a simple command line prompt match β€” this one should be named "generic".

# example only!
prompt generic
    match /> ?$/

πŸ¦‹ Desirable Prompt and Macros πŸ¦‹

to cleanly disconnect from your device session, you might wanna include a macro named "disconnect" with the relevant command. and note: there's no need for a "match" statement in this macro, because the device should already have detached by then! bye bestie πŸ‘‹

# example only!
macro disconnect
    send exit

for paging support, include either just a "prompt" macro, or two macros named "enable_paging" and "disable_paging" β€” depends on what your device needs. and in all cases there has to be exactly one substitution (%s), which is where the number of page lines gets slotted into the command.

# example only!
macro paging
    send terminal length %s

for privileged mode (super-user) support: first include a prompt named "privileged", and then include macros named "begin_privileged" and "end_privileged" to enter and leave the mode, respectively. heads up though β€” both macros will need explicit match statements, because the prompt you get after issuing the command is gonna be different from the one before. keep that in mind, okay?

# example only!
prompt privileged
    match /# ?$/

macro begin_privileged
    send enable
    match user or pass or privileged

macro end_privileged
    send disable
    match generic

similarly for configure mode: include a prompt named "configure" first, then macros named "begin_configure" and "end_configure" to enter and leave the mode, respectively. same deal β€” both macros need explicit match statements, because the prompt after the command differs from the prompt before it. πŸ’€

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

macro begin_configure
    send configure terminal
    match configure

macro end_configure
    send exit
    match privileged

and that's the whole page, bestie!! this was written up by the fine folks behind perl v5.36.0, dated 2023-10-28 β€” go forth and phrasebook responsibly πŸ“βœ¨πŸ’œ

πŸ“¦ where this page comes from