Wheel::ReadLine is tip top. You have command events and everything just works. POE can be a little frightening at first, but you'll get the hang of it.
| [reply] |
| [reply] |
The last time I needed such a think I used readline and did it manually because reading and parsing isn't difficult.
However that was before I knew about Term::Shell, which looks like it would suit your needs.
| [reply] |
Here's an example to get you started. There are three commands: system, version, and exit. Note that subs for the commands start with "sub run_system", etc. Prefix run to the command. I don't have any Cisco devices, so I can't help you there. #!/usr/bin/perl
use strict;
use warnings;
my $obj = cios->new();
$obj->cmdloop;
package cios;
use base qw(Term::Shell);
use CPAN;
sub prompt_str {
my $cwd = 'cwd';
$cwd =~ s[^\Q$ENV{HOME}\E][~];
"cios> "
}
sub run_system {
print "\nYour System:\n",
"Perl $]\n",
"$^O\n",
"$0\n\n";
}
sub run_version {
my $mod = 'Term::Shell';
for $mod(CPAN::Shell->expand("Module", $mod)) {
print "The current version is: ",
$mod->cpan_version, "\n",
"The installed version is: ",
$mod->inst_version, "\n",
$mod->inst_file, "\n";
}
}
| [reply] [d/l] |
The frameworks for building command-line apps also have "console" commands typically. See this node for a review of some.
| [reply] |