Ticket #240: smartctl_sata.pl

File smartctl_sata.pl, 604 bytes (added by acasis, 11 years ago)
Line 
1my $i=98;
2my $counter=1;
3my @serial;
4for ($i=98; $i<123; $i++) {
5        $counter=1;
6        system "smartctl.exe -a sd".chr($i)." -d sat >>temp.txt";
7        if (open(temp, "temp.txt")) {
8                while ( my $line = <temp> ) {
9                        if ($counter == 6) {
10                                @serial = split( / / , $line ); 
11                                chomp(@serial);
12                                print "Serial: ".$serial[5]."\n";
13                                last;
14                        }
15                        else {
16                                $counter++;
17                        }
18                }
19                if ($counter < 6) {
20                        print "No drive found.\n";
21                }
22                else {
23                        system "copy temp.txt ".$serial[5].".txt";;
24                }
25                close(temp);
26                system "del temp.txt";
27        }
28        else {
29                print "No drive found.\n"
30        }
31       
32       
33}