my $dbargs = {AutoCommit => 0, PrintError => 1}; my $dbh = DBI->connect("dbi:SQLite:dbname=$database","","",$dbargs); if ($dbh->err()) { die "$DBI::errstr\n"; } my $sth = $dbh->prepare(q {select ' ' || (server_types.offset + ports.physical - 1) || ' ' || servers.address from ports left join servers on ports.server_id = servers.id left join server_types on servers.server_type_id = server_types.id where ports.hostname LIKE "IT-LT-%" AND server_types.ssh = "t" }); $sth->execute; open FH, '> OutputDBssh.txt' or die "Kann Datei nicht schreiben"; select(FH); while (@row = $sth->fetchrow_array) { print "FT -l :%s\n", $row[0]; } my $sth = $dbh->prepare(q {select ' ' || servers.address || ' ' || (server_types.offset + ports.physical - 1) from ports left join servers on ports.server_id = servers.id left join server_types on servers.server_type_id = server_types.id where ports.hostname LIKE "IT-LT-%" AND server_types.ssh = "f" }); $sth->execute; open TFH, '> OutputDBtelnet.txt' or die "Kann Datei nicht schreiben"; select(TFH); while (@row = $sth->fetchrow_array) { printf "File%s\n",$row[0]; } close TFH; $dbh->commit(); $dbh->disconnect(); my $datei = "OutputDBssh.txt"; if( open(SFH, $datei) ) { print "ok\n"; while ( ) { print $_; } } else { die "Error: couldn't open file '$datei': $!\n"; }