| 1 | package Ipmitool; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.010000; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Net::Ping; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | require Exporter; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||
| 14 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||
| 15 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # This allows declaration use Ipmitool ':all'; | ||||||||||||||||||||||||||||
| 18 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||||||||||
| 19 | # will save memory. | ||||||||||||||||||||||||||||
| 20 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | ) ] ); | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | our @EXPORT = qw( | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 1 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | our %FRU; | |||||||||||||||||||||||||||
| 33 | # Preloaded methods go here. | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||||||||||||||||||||
| 36 | sub new | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 39 | 0 | my $self = {}; | |||||||||||||||||||||||||||
| 40 | 0 | bless($self,$class); | |||||||||||||||||||||||||||
| 41 | 0 | $self->_init(@_); | |||||||||||||||||||||||||||
| 42 | 0 | return ($self); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | sub remove_spaces | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
remove_spaces: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 47 | 0 | my $string = shift; | |||||||||||||||||||||||||||
| 48 | 0 | chomp($$string); | |||||||||||||||||||||||||||
| 49 | 0 | $$string =~ s/^\s+//; #remove leading spaces | |||||||||||||||||||||||||||
| 50 | 0 | $$string =~ s/\s+$//; #remove trailing spaces | |||||||||||||||||||||||||||
| 51 | #print "String passed: $string\n"; | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub fru | ||||||||||||||||||||||||||||
| 55 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
fru: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 57 | 0 | my $h = $self->{"ipaddress"}; | |||||||||||||||||||||||||||
| 58 | 0 | my $u = $self->{"username"}; | |||||||||||||||||||||||||||
| 59 | 0 | my $p = $self->{"password"}; | |||||||||||||||||||||||||||
| 60 | 0 | ▶ | open PASSFILE, ">file" or die "Unable to create password file\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | print PASSFILE "$p"; | |||||||||||||||||||||||||||
| 62 | 0 | close(PASSFILE); | |||||||||||||||||||||||||||
| 63 | 0 | system("ipmitool -H $h -U $u -f file fru > .fru.out"); | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ( $? == -1 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | { | ||||||||||||||||||||||||||||
| 66 | 0 | print "command failed: $!\n"; | |||||||||||||||||||||||||||
| 67 | }else | ||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||
| 69 | 0 | printf "command exited with value %d\n", $? >> 8; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | open FRU,".fru.out" or die "Unable to open .fru.out file\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | my @fru_line_numbers; | |||||||||||||||||||||||||||
| 75 | 0 | ▶ | while(<FRU>) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | { | ||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if(/FRU Device Description/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | { | ||||||||||||||||||||||||||||
| 79 | 0 | push(@fru_line_numbers,$.); | |||||||||||||||||||||||||||
| 80 | 0 | my @a1 = split(":"); | |||||||||||||||||||||||||||
| 81 | 0 | chomp($a1[1]); | |||||||||||||||||||||||||||
| 82 | #print "element $a1[1]\n"; | ||||||||||||||||||||||||||||
| 83 | 0 | my @a2 = split(/[()]/,$a1[1]); | |||||||||||||||||||||||||||
| 84 | #print "name : $a2[1]\n"; | ||||||||||||||||||||||||||||
| 85 | 0 | my $fruname = $a2[0]; | |||||||||||||||||||||||||||
| 86 | 0 | my $id = $a2[1]; | |||||||||||||||||||||||||||
| 87 | 0 | $id =~ s/ID//g; | |||||||||||||||||||||||||||
| 88 | 0 | print "$. fruname : $fruname and ID is : $id\n"; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | 0 | close(FRU); | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | for (my $j=0;$j<$#fru_line_numbers;$j=$j+1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||
| 95 | 0 | create_fru_hash(\$self,$fru_line_numbers[$j], $fru_line_numbers[$j+1]); | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | #print Dumper(\%FRU); | ||||||||||||||||||||||||||||
| 99 | 0 | return ( %FRU ); | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | sub find_records | ||||||||||||||||||||||||||||
| 103 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
find_records: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 104 | 0 | my $start = shift; | |||||||||||||||||||||||||||
| 105 | 0 | my $end = shift; | |||||||||||||||||||||||||||
| 106 | 0 | my $array1 = shift; | |||||||||||||||||||||||||||
| 107 | 0 | my $flag = 0; | |||||||||||||||||||||||||||
| 108 | #print "start : $start and end is : $end\n"; | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | open FRU1,".fru.out" or die "Unable to open .fru.out file\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | while(<FRU1>) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if (($. > $start) && ($. < $end)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$. > $start and $. < $end
MC/DC0%0/2
$. > $start and $. < $end
$. > $start
$. < $end
Truth table0%0/3
A and B
A= $. > $startB= $. < $end
| |||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ( ! (/:/ | /^\s*$/) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||
| 116 | 0 | push(@$array1,$.); | |||||||||||||||||||||||||||
| 117 | 0 | $flag = 1; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | 0 | close(FRU1); | |||||||||||||||||||||||||||
| 122 | 0 | return($flag); | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | sub create_fru_hash | ||||||||||||||||||||||||||||
| 126 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
create_fru_hash: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 127 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 128 | 0 | my $start = shift; | |||||||||||||||||||||||||||
| 129 | 0 | my $end = shift; | |||||||||||||||||||||||||||
| 130 | 0 | my $temp_fru_name; | |||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | print "start : $start and end : $end\n"; | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | my @rec_line_numbers; | |||||||||||||||||||||||||||
| 135 | 0 | my $ret= find_records($start,$end,\@rec_line_numbers); | |||||||||||||||||||||||||||
| 136 | 0 | foreach(@rec_line_numbers) | |||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||
| 138 | 0 | print "line numbers: $_\n"; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | 0 | ▶ | open FRU,".fru.out" or die "Unable to open .fru.out file\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if ( $ret == 1 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||
| 144 | 0 | my $backup_end = $end; | |||||||||||||||||||||||||||
| 145 | 0 | $end = $rec_line_numbers[0]; | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | 0 | ▶ | while(<FRU>) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | { | ||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ( ($. >= $start) && ($. < $end) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$. >= $start and $. < $end
MC/DC0%0/2
$. >= $start and $. < $end
$. >= $start
$. < $end
Truth table0%0/3
A and B
A= $. >= $startB= $. < $end
| |||||||||||||||||||||||||||||
| 150 | { | ||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if(! /^\s*$/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||
| 153 | #print $_; | ||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ( /FRU Device Description/ ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | { | ||||||||||||||||||||||||||||
| 156 | 0 | my @a1 = split(":"); | |||||||||||||||||||||||||||
| 157 | 0 | chomp($a1[1]); | |||||||||||||||||||||||||||
| 158 | 0 | my @a2 = split(/[()]/,$a1[1]); | |||||||||||||||||||||||||||
| 159 | 0 | $temp_fru_name = $a2[0]; | |||||||||||||||||||||||||||
| 160 | 0 | remove_spaces(\$temp_fru_name); | |||||||||||||||||||||||||||
| 161 | 0 | my $id = $a2[1]; | |||||||||||||||||||||||||||
| 162 | 0 | $id =~ s/ID//g; | |||||||||||||||||||||||||||
| 163 | 0 | remove_spaces(\$id); | |||||||||||||||||||||||||||
| 164 | 0 | $FRU{$temp_fru_name}{ID} = $id; | |||||||||||||||||||||||||||
| 165 | }else | ||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||
| 167 | #print "inside else : $_\n"; | ||||||||||||||||||||||||||||
| 168 | 0 | my @a1 = split(":"); | |||||||||||||||||||||||||||
| 169 | #print "$a1[0] : $a1[1]\n"; | ||||||||||||||||||||||||||||
| 170 | 0 | remove_spaces(\$a1[0]); | |||||||||||||||||||||||||||
| 171 | 0 | remove_spaces(\$a1[1]); | |||||||||||||||||||||||||||
| 172 | 0 | $FRU{$temp_fru_name}{$a1[0]} = $a1[1]; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if($ret == 1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | { | ||||||||||||||||||||||||||||
| 180 | 0 | seek(FRU,0,0); | |||||||||||||||||||||||||||
| 181 | 0 | ▶ | for(my $i = 0; $i<$#rec_line_numbers; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | { | ||||||||||||||||||||||||||||
| 183 | 0 | print "inside for loop \n"; | |||||||||||||||||||||||||||
| 184 | 0 | add_sub_record($temp_fru_name,$rec_line_numbers[$i],$rec_line_numbers[$i+1]); | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | 0 | close(FRU); | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | sub add_sub_record | ||||||||||||||||||||||||||||
| 191 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
add_sub_record: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 192 | 0 | my $fruname = shift; | |||||||||||||||||||||||||||
| 193 | 0 | my $start = shift; | |||||||||||||||||||||||||||
| 194 | 0 | my $end = shift; | |||||||||||||||||||||||||||
| 195 | 0 | my $rec_name; | |||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | open F1, ".fru.out" or die "Unable to open .fru.out file\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | #print "inside add_sub_record func $fruname $start : $end\n"; | ||||||||||||||||||||||||||||
| 199 | 0 | ▶ | while(<F1>) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ( $. == $start ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||
| 203 | 0 | $rec_name = $_; | |||||||||||||||||||||||||||
| 204 | 0 | remove_spaces(\$rec_name); | |||||||||||||||||||||||||||
| 205 | #print "rec_name : $rec_name\n"; | ||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if ( ($. > $start ) && ( $. < $end ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$. > $start and $. < $end
MC/DC0%0/2
$. > $start and $. < $end
$. > $start
$. < $end
Truth table0%0/3
A and B
A= $. > $startB= $. < $end
| |||||||||||||||||||||||||||||
| 208 | { | ||||||||||||||||||||||||||||
| 209 | #print "inside if block\n"; | ||||||||||||||||||||||||||||
| 210 | 0 | my @a1 = split(":"); | |||||||||||||||||||||||||||
| 211 | 0 | remove_spaces(\$a1[0]); | |||||||||||||||||||||||||||
| 212 | 0 | remove_spaces(\$a1[1]); | |||||||||||||||||||||||||||
| 213 | #print "$fruname : $rec_name : $a1[0] : $a1[1]\n"; | ||||||||||||||||||||||||||||
| 214 | 0 | $FRU{$fruname}{$rec_name}{$a1[0]} = $a1[1]; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | 0 | close(F1); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | sub print | ||||||||||||||||||||||||||||
| 221 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
print: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 222 | 0 | my $self= shift; | |||||||||||||||||||||||||||
| 223 | 0 | foreach (keys (%{$self})) | |||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||
| 225 | 0 | print "$_: $self->{$_}\n" | |||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | #print "IP Address : $self->{ipaddress}\n" if (defined($self->{ipaddress})); | ||||||||||||||||||||||||||||
| 228 | #print "Username : $self->{username}\n" if (defined($self->{username})); | ||||||||||||||||||||||||||||
| 229 | #print "Password : $self->{password}\n" if (defined($self->{password})); | ||||||||||||||||||||||||||||
| 230 | 0 | return 0; | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | sub bmc | ||||||||||||||||||||||||||||
| 234 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
bmc: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 235 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 236 | 0 | my $cmd = shift; | |||||||||||||||||||||||||||
| 237 | 0 | my @op = `ipmitool -H $self->{ipaddress} -U $self->{username} -f file bmc $cmd`; | |||||||||||||||||||||||||||
| 238 | #print @op; | ||||||||||||||||||||||||||||
| 239 | 0 | foreach(@op) | |||||||||||||||||||||||||||
| 240 | { | ||||||||||||||||||||||||||||
| 241 | 0 | print "$_"; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | sub _init | ||||||||||||||||||||||||||||
| 246 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | my ($self,@args)=@_; | |||||||||||||||||||||||||||
| 249 | 0 | ▶ | while (@args) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||
| 251 | 0 | my ($x); | |||||||||||||||||||||||||||
| 252 | 0 | ($x)=shift(@args); | |||||||||||||||||||||||||||
| 253 | 0 | ▶ | if ($x eq "-ipaddress") | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||
| 255 | 0 | $self->{"ipaddress"}=shift(@args); | |||||||||||||||||||||||||||
| 256 | 0 | my $p = Net::Ping->new(); | |||||||||||||||||||||||||||
| 257 | 0 | ▶ | if (!$p->ping($self->{"ipaddress"})) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | { | ||||||||||||||||||||||||||||
| 259 | #print " Machine is alive\n"; | ||||||||||||||||||||||||||||
| 260 | 0 | die "$self->{ipaddress} : invalid ip address or machine is unreachable\n"; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | 0 | $p->close(); | |||||||||||||||||||||||||||
| 263 | } elsif ($x eq "-username") | ||||||||||||||||||||||||||||
| 264 | { | ||||||||||||||||||||||||||||
| 265 | 0 | $self->{"username"}=shift(@args); | |||||||||||||||||||||||||||
| 266 | } elsif ($x eq "-password") | ||||||||||||||||||||||||||||
| 267 | { | ||||||||||||||||||||||||||||
| 268 | 0 | $self->{"password"}=shift(@args); | |||||||||||||||||||||||||||
| 269 | 0 | ▶ | open PASSFILE, ">file" or die "Unable to create password file\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | 0 | print PASSFILE "$self->{password}"; | |||||||||||||||||||||||||||
| 271 | 0 | close(PASSFILE); | |||||||||||||||||||||||||||
| 272 | } else | ||||||||||||||||||||||||||||
| 273 | { | ||||||||||||||||||||||||||||
| 274 | 0 | die "Invalid argument : $x\n"; | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 0 | return(0); | |||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | # Preloaded methods go here. | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 1 | 1; | |||||||||||||||||||||||||||
| 286 | __END__ | ||||||||||||||||||||||||||||