#!/usr/bin/perl use strict; use warnings; use Net::Telnet; my $uri = shift @ARGV or die "IP address needed \n Usage: ./runssh 10.10.10.77 outputfile"; my $a = shift @ARGV or die "output file needed \n usage: ./runssh 10.10.10.77 outputfile"; my $telnet = new Net::Telnet (Timeout=>15 ,Input_log => $a ); $telnet->open($uri); $telnet->waitfor('/login: /i'); $telnet->print('OOQ91'); #put your login here $telnet->waitfor('/Password: /i'); $telnet->print('Password'); #put your password here print "Login is successful \n"; $telnet->prompt('/\w+# $/'); $telnet->waitfor($telnet->prompt); ### put some commands in here ### $telnet->cmd("terminal length 0"); $telnet->cmd("show interface brief"); $telnet->cmd("sh int desc"); $telnet->cmd("sh flogi data"); $telnet->cmd("sh zone act"); $telnet->waitfor($telnet->prompt); my $out = $telnet->print('exit'); print $out; my $fname = "received_data.txt"; open (my $fh, "<", $fname) or die "Can't open"; while (<$fh>) { print if /ip prefix-list/; }