Net::C...sebook(3pm)
π 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
- debian trixie: libnet-cli-interact-perl 2.400002-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-cli-interact-perl 2.400002-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-cli-interact-perl 2.400002-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-cli-interact-perl 2.400002-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms