for my $router ( @$router_data ) { my $tty; ### Create SSH Session print "\n" . "Logging into $router->{routerName}..." . " \n"; my $ssh = Net::SSH::Expect->new ( host => $router->{routerName}, password=> $pWord, user => $uName, timeout => '3', raw_pty => 1 ); ### Logon to the Router $tty = $ssh->login(); if($tty !~ /$router->{routerName}/) { die "Error: no prompt received.\n\n"; } if ( $Action eq 'status' ) { checkStatus($router->{routerName,$ssh}); } } sub checkStatus { my $routerName = $_[0]; my $ssh = $_[1]; my $test; if ($routerName eq 'asr01') { $test = $ssh->exec("show run | in hostname "); } else { $test = $ssh->exec("show clock"); } print $test; }