Link to home
Start Free TrialLog in
Avatar of ashvillerob
ashvillerob

asked on

Combine two PERL scripts

I use one script to pull data from a Cisco router then the second scripts uses the output file of the frist script to output the final file.

I wish to combine these into a single script.

FIRST SCRIPT:
#!/usr/bin/perl

#    Use the script as follows C:> PERL script.pl ipaddress > output_file_name
#
use Net::Telnet;
my $MB = 1024 * 1024;
open (FILE,@ARGV[0])|| die "Sorry, I can't seem to find @ARGV[1]. Please check
$my @lines;
the spelling.\n";
print "\n";
while (<FILE>) {
my $ip = $_;

my $t = Net::Telnet->new(Timeout => 240,
                    Prompt => '/.*#/',
                          Host => $ip);
my $debug=$ARGV[1];
$t->max_buffer_length(5 * $MB);
$t->login('username','password');
$t->cmd("terminal length 0");
print $ip;
my @lines = $t->cmd("show cable modem docsis device-class | in MTA");
print "\n\n@lines\n";
$t->cmd("");
$t->close;
}

SECOND SCRIPT
perl -ane "print \"clear cable modem $F[0] reset\n\"" mtas > newfile.txt

BTW....running this on Windows


ASKER CERTIFIED SOLUTION
Avatar of Adam314
Adam314

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ashvillerob
ashvillerob

ASKER

I get the following error:

Can't locate object method "Select" via package "All" (perhaps you forgot to load "All"?) at script.pl line 29, <$File> line
21.

I'm assuming you got it working because you accepted an answer.  Is it working?
Yes, It was my error, thansk!