smoss74 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Folks, I'm having some trouble logging into a Cisco switch using Net::Session::Appliance. I'm pretty sure I had this working some time ago but its failing now on a different host possibly due to a more recent perl version.
#!/usr/bin/perl use Net::Appliance::Session; my $pass="password"; my $user="username"; my $host="10.10.10.10"; my $ssh = Net::Appliance::Session->new( personality => 'ios', host => +$host, transport => 'SSH'); $ssh->connect ( name => $user, password => $pass); $ssh->cmd("config term"); $ssh->cmd(" interface fastethernet 0/1"); $ssh->cmd(" desc test"); $ssh->close;
When I run the script I get the following error;

login failed to remote host - prompt does not match at /usr/local/share/perl/5.10.1/Net/Appliance/Session/Transport.pm line 78.

Any help would be appreciated!

Kind regards.

Replies are listed 'Best First'.
Re: Problem logging onto Cisco Switch using Net::Session::Appliance
by hdb (Monsignor) on Mar 26, 2013 at 12:37 UTC

    Find below CPAN documentation of module Net::Appliance::Session. Looks slightly different to your call of connect.

    $s->connect({ username => 'username', password => 'loginpass' });
      Thanks for the reply, I've tried the different syntax but unfortunately I'm still getting the same result. I'm specifying ios and the prompt is standard # but it's still not working.
Re: Problem logging onto Cisco Switch using Net::Session::Appliance
by McA (Priest) on Mar 26, 2013 at 13:28 UTC

    Hi,

    as the error message states: The prompt you get after connection ist not the prompt defined by the personality ios. Have a look at Net::CLI::Interact::Manual::Tutorial. Check what prompt is expected by the personality and what prompt you get when you connect manually.

    Interestingly is ios ambitious, isn't it? ;-)

    McA

Re: Problem logging onto Cisco Switch using Net::Session::Appliance
by regexes (Hermit) on Mar 26, 2013 at 13:35 UTC