9 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
#!/usr/bin/perl
$raidtab = "/etc/raidtab";
## /etc/raidtab oeffnen und devices in temporaeres Array schreiben
open(RAIDTAB, $raidtab) || die "Unable to read from /etc/raidtab : $!";
while(<RAIDTAB>)
{
foreach $device (split(/ |raiddev|device/,$_)) {
#print $device;
if ($device =~ m/\/dev\//ig) {
push (@raid_tab, "$device");
}
}
}
close (RAIDTAB);
##raiddevices(md0, etc.) in eigenes Array schreiben (das koennte man wahrscheinlich im ersten Block bereits handlen...)
foreach $raiddev (@raid_tab) {
if ($raiddev =~ m/md/ig) {
push (@raids, "$raiddev");
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
raiddev /dev/md0
raid-level 1
nr-raid-disks 2
nr-spare-disks 0
persistent-superblock 1
chunk-size 4
device /dev/hdc1
raid-disk 0
device /dev/hdd1
raid-disk 1
raiddev /dev/md1
raid-level 1
nr-raid-disks 2
nr-spare-disks 0
persistent-superblock 1
chunk-size 4
device /dev/hdc2
raid-disk 0
device /dev/hdd2
raid-disk 1
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
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $raidtab = "./raidtab.txt";
my %info;
{
my $mnt;
local $/ = "\n\n";
open(my $fh,"<",$raidtab) or die $!;
while(my $entry = <$fh>){
my ($device,@infos) = split(/\r?\n/,$entry);
print $device;
($device) = $device =~ m~(/dev/.*?)$~;
chomp(@infos);
for my $detail(@infos){
my (undef,$key,$value) = split(/\s+/,$detail);
if($key eq 'device'){
$mnt = $value;
}
elsif($key eq 'raid-disk'){
$info{$device}->{devices}->{$mnt} = $value;
}
else{
$info{$device}->{$key} = $value;
}
}
}
close $fh;
}
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
#!/usr/bin/perl
$raidtab = "/etc/raidtab";
## /etc/raidtab oeffnen und devices in temporaeres Array schreiben
open(RAIDTAB, $raidtab) || die "Unable to read from /etc/raidtab : $!";
while(<RAIDTAB>)
{
foreach $device (split(/ |raiddev|device/,$_)) {
#print $device;
if ($device =~ m/dev\/md/ig) {
push (@md_s, "$device");
}
elsif ($device =~ m/dev\/[a-z]d[a-z][0-9]/ig) {
push (@disks, "$device"); }
}
}
close (RAIDTAB);
#print @md_s; #Debug
#print @disks; #Debug
$how_many_disks_do_we_have_here = $#disks;
#print "\n$how_many_disks_do_we_have_here\n"; #Debug
for ($i=0; $i <= $how_many_disks_do_we_have_here; $i++) {
$o = $i + 2;
$temp = $disks[$i];
if ($o/2==true) {
push (@related_disks[$o], $temp, $disks[$o]);
}
}
QuoteTruth and Falsehood
The number 0, the strings '0' and '', the empty list "()", and "undef" are all false in a boolean context. All other values are true. Negation of a true
value by "!" or "not" returns a special false value. When evaluated as a string it is treated as '', but as a number, it is treated as 0.
QuoteUnd nein, Perl kennt kein "true".
9 Einträge, 1 Seite |