![]() |
|< 1 2 3 4 >| | ![]() |
34 Einträge, 4 Seiten |
1
2
my @ips = split(/ /,$line); # in $line steht die Zeile mit den IPs
print "Es sind ",scalar(@ips)," IPs\n"; # scalar() liefert die Anzahl der Elemente
1
2
3
4
5
6
GetOptions(
"p|=s" => \$password,
"i|ip=s" => \$ip,
"f|fille=s" => \$file,
"h|help" => \$help,
)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/perl
use warnings;
use strict;
use Getopt::Long;
my ($filterPassword, $filterIp, $file);
my $help = 0;
# z.B. program.pl -p password -i 127.0.0.1 -file datei.txt
# oder: program.pl -h
GetOptions(
"password=s" => \$filterPassword,
"ip=s" => \$filterIp,
"file=s" => \$file,
"help" => \$help,
);
if ($help) {
# &PrintHelp....
exit 1;
} # if
# vielleicht hier noch ueberpruefen, ob $filterPassword und $filterIp gesetzt sind....
unless (open (LOG, "<", $file)) {
die "Error: couldn't open '$file': $!\n";
} # unless
my @filteredLines = ();
while (<LOG>) {
chomp($_);
my (undef, $pass, $ip) = split(/ /, $_);
if ($pass eq $filterPassword and $ip eq $filterIp) {
print "gefiltert: $_\n";
push (@filteredLines, $_);
} # if
} # while
close (LOG);
foreach (@filteredLines) {
print "$_\n";
} # foreach
perl -ne "@cols=split(/ /); print if $cols[1] eq 'geheim' and $cols[2] eq '127.0.0.1'" file.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/perl
use warnings;
use strict;
use Getopt::Long;
my ($filterPassword, $filterIp, $file);
my $help = 0;
# z.B. program.pl -p password -i 127.0.0.1 -file datei.txt
# oder: program.pl -h
GetOptions(
"password=s" => \$filterPassword,
"ip=s" => \$filterIp,
"file=s" => \$file,
"help" => \$help,
);
if ($help) {
# &PrintHelp....
exit 1;
} # if
# vielleicht hier noch ueberpruefen, ob $filterPassword und $filterIp gesetzt sind....
unless (open (LOG, "<", $file)) {
die "Error: couldn't open '$file': $!\n";
} # unless
my @filteredLines = ();
while (<LOG>) {
chomp($_);
my (undef, $pass, $ip) = split(/ /, $_);
if ($pass eq $filterPassword and $ip eq $filterIp) {
print "gefiltert: $_\n";
push (@filteredLines, $_);
} # if
} # while
close (LOG);
foreach (@filteredLines) {
print "$_\n";
} # foreach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/perl
use warnings;
use strict;
use Getopt::Long;
my ($filterPassword, $filterIp, $file, $file2);
my $help = 0;
# z.B. program.pl -p password -i 127.0.0.1 -file datei.txt
# oder: program.pl -h
GetOptions(
"password=s" => \$filterPassword,
"ip=s" => \$filterIp,
"file=s" => \$file,
"file2=s" => \$file2,
"help" => \$help,
);
if ($help) {
# &PrintHelp....
exit 1;
} # if
# vielleicht hier noch ueberpruefen, ob $filterPassword und $filterIp gesetzt sind....
unless (open (LOG, "<", $file)) {
die "Error: couldn't open '$file': $!\n";
} # unless
my %filteredLines;
while (<LOG>) {
chomp($_);
my ($ip, $pass) = split(/ /, $_);
if ($pass eq $filterPassword and $ip eq $filterIp) {
$filteredLines{$_} = 1;
} # if
} # while
close (LOG);
open(FILE2,"<$file2") or die $!;
while(<FILE2>){
chomp $_;
my ($ip, $pass) = split(/ /, $_);
if ($pass eq $filterPassword and $ip eq $filterIp) {
print $_,"\n" if($filteredLines{$_});
} # if
}
close FILE2;
1
2
~ 34> perl test_ip.pl -ip 127.0.0.1 -password password1 -file ip1.txt -file2 ip2.txt
127.0.0.1 password1 id1
129.0.0.1 test1 id4 129.0.0.2 test3 id5 127.0.0.1 password1 id1
![]() |
|< 1 2 3 4 >| | ![]() |
34 Einträge, 4 Seiten |