8 Einträge, 1 Seite |
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
sub gen2nfs_sub_ifconfig_ipv4 {
my $ethif = shift;
my $ifconfig = "$IFCONFIG";
my $string = 'inet\saddr:';
local *IFCONFIG;
open (IFCONFIG, "$ifconfig $ethif 2>&1 |") || die ("ERROR (gen2nfs_sub_ifconfig_ipv4): $! $_");
while(<IFCONFIG>) {
# search IP 123.123.123.123
# ddd.ddd.ddd.ddd
# \d = digit
# {1,3} 1,2 or 3 digits
if ( /^.*$string(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/ ) {
return "$1";
last;
} else {
die ("ERROR (gen2nfs_sub_ifconfig_ipv4): $! $_");
};
}
close (IFCONFIG);
}
Sehr wahrscheinlich hier ??? -->> open (IFCONFIG, "$ifconfig $ethif 2>&1 |") || die ("ERROR (gen2nfs_sub_ifconfig_ipv4): $! $_");
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
sub gen2nfs_sub_ifconfig_mac {
my $ethif = shift;
my $ifconfig = "$IFCONFIG";
my $string = 'HWaddr';
local *IFCONFIG;
open (IFCONFIG, "$ifconfig $ethif 2>&1 |") || die ("ERROR (gen2nfs_sub_ifconfig_mac): $! $_");
while(<IFCONFIG>) {
# search MAC 00:00:00:00:00:00
# ww:ww:ww:ww:ww:ww
# \w = word
if ( /^.*$string\s(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ ) {
return "$1";
last;
} else {
die ("ERROR (gen2nfs_sub_ifconfig_mac): $! $_" );
};
}
close (IFCONFIG);
}
1
2
3
4
5
6
7
our $IFCONFIG = '/sbin/ifconfig';
my $mac = gen2nfs_sub_ifconfig_mac('eth0');
my $ip = gen2nfs_sub_ifconfig_ipv4('eth0');
print "\n***$mac***\n";
print "\n***$ip***\n";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
sub gen2nfs_sub_ifconfig_ipv4 {
my $ethif = shift;
my $ifconfig = "$IFCONFIG";
my $string = 'inet\saddr:';
local *IFCONFIG;
open (IFCONFIG, "$ifconfig $ethif 2>&1 |") || die ("ERROR:1 (gen2nfs_sub_ifconfig_ipv4): $! $_");
while(<IFCONFIG>) {
# search IP 123.123.123.123
# ddd.ddd.ddd.ddd
# \d = digit
# {1,3} 1,2 or 3 digits
if ( /.*$string(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/ ) {
return "$1";
last;
};
}
close (IFCONFIG);
}
8 Einträge, 1 Seite |