Gesamte code
use strict;
use warnings;
use DBI;
use Net::Telnet::Cisco;
use Digest::MD5;
our $dbh;
open(DAT, '<','../gate_common/MySQLAccount.txt') or die"Could not open SQL-Data-file!";
$raw_data=<DAT>;
close(DAT);
chomp $raw_data;
my ($host,$user,$pass,$db) = split(/:/, $raw_data);
print "host ".$host."\n"."user ".$user."\n"."pass ".$pass."\n"."db ".$db."\n";
$dbh = DBI->connect("DBI:mysql:".$db.":".$host,$user,$pass) or die "Connect Error: $DBI::errstr()\n";
my @Routerlist =(
[ qw/1 router3 10.100.2.99 admin router/ ],
[ qw/2 router9 10.100.2.105 admin router/ ],
);
for my $cisco ( @ciscolist ) {
get_Router( @{ $cisco } );
}
$dbh->disconnect;
sub get_Router
{
my $dbh;
my $neid=shift;
my $ip=shift;
my $user=shift;
my $pwd=shift;
my ($query,$sth,$sth1,$execu,$newdata,$ds, $datarefid);
$query="INSERT INTO DATEN(ID,Type,Name,Address,Referenz,Data_RefIerenz,User_ID) VALUES ('',2,'???','$ip',$neid,0,0)";
$sth = $dbh->prepare($query) or die "Querry Error prepare: $DBI::errstr\n";
$ds = $sth->execute or die "Querry Error execute: $DBI::errstr\n";
$datarefid = $dbh->{'mysql_insertid'};
$sth->finish();
}