C:\Patch_Adams\scripts>hotfix_update.pl IO error: opening c:/Patch_Adams/Patches/Windows2000-KB824146-x86-ENU.exe for re ad : No such file or directory Archive::Zip::Archive::read('Archive::Zip::Archive=HASH(0x2f4895c)','c:/ Patch_Adams/Patches/Windows2000-KB824146-x86-ENU.exe') called at C:\Patch_Adams\ scripts\hotfix_update.pl line 83 main::Add_Hotfix('Windows2000-KB824146-x86-ENU.exe','win2k') called at C :\Patch_Adams\scripts\hotfix_update.pl line 177 read error at C:\Patch_Adams\scripts\hotfix_update.pl line 83. #### use strict; use Win32::ODBC; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); our $PATCH_PATH ="c:/Patch_Adams/Patches/"; our $DSN = "scanner"; our $TABLE = "hotfixes"; our @valid_os = ("nt4wk","nt4sv","win2k","winxp","w2003"); sub Check_Array(\@\@){ my ($installed_ref , $hotfix_ref) = @_; my %installed = (); my @ready2install = (); foreach my $hotfix (@{$hotfix_ref}){$installed{$hotfix}=1} foreach my $hotfix (@{$installed_ref}){ unless ($installed{$hotfix}){ push (@ready2install , $hotfix); } } return @ready2install; } sub Add_Hotfix($$){ my ($hotfix , $os) = @_; my $zip = Archive::Zip->new(); die 'read error' unless $zip->read("${PATCH_PATH}${hotfix}") == AZ_OK; } my (@installed_nt4wk , @installed_nt4sv , @installed_win2k , @installed_w2003 , @installed_winxp); my (@hotfix_nt4wk , @hotfix_nt4sv , @hotfix_win2k , @hotfix_w2003 , @hotfix_winxp); my (@ready_nt4wk , @ready_nt4sv , @ready_win2k, @ready_w2003 , @ready_winxp); foreach my $os (@valid_os){ my $path_os = "${PATCH_PATH}${os}"; opendir (DIR, $path_os) or die "$!: Can not open $path_os!"; while(defined(my $installed_hotfix = readdir(DIR))){ next if $installed_hotfix =~/^\.\.?$/; chomp ($installed_hotfix); push (@installed_nt4wk , $installed_hotfix) if ($os eq 'nt4wk'); push (@installed_nt4sv , $installed_hotfix) if ($os eq 'nt4sv'); push (@installed_win2k , $installed_hotfix) if ($os eq 'win2k'); push (@installed_w2003 , $installed_hotfix) if ($os eq 'w2003'); push (@installed_winxp , $installed_hotfix) if ($os eq 'winxp'); } closedir (DIR); } #** If all these directories are empty we need not run any more of this #** program at all. my $length_nt4wk = scalar (@installed_nt4wk); my $length_nt4sv = scalar (@installed_nt4sv); my $length_win2k = scalar (@installed_win2k); my $length_w2003 = scalar (@installed_w2003); my $length_winxp = scalar (@installed_winxp); my $length_of_all = $length_nt4wk + $length_nt4sv + $length_win2k + $length_w2003 + $length_winxp; die "No hotfix files are installed in directory $PATCH_PATH\n" if ($length_of_all eq 0); #** Open the database and read into arrays the hotfixes for each os. my $db = new Win32::ODBC($DSN); die "$! : DSN $DSN not available." if (! $db); die "$! : there is a problem with table $TABLE" if( $db->Sql("SELECT * FROM $TABLE" )); my %hotfix_record; while ($db->FetchRow){ %hotfix_record = $db->DataHash("operating_system","software_name"); push (@hotfix_nt4wk, $hotfix_record{software_name}) if ($hotfix_record{operating_system} eq 'nt4wk'); push (@hotfix_nt4sv, $hotfix_record{software_name}) if ($hotfix_record{operating_system} eq 'nt4sv'); push (@hotfix_win2k, $hotfix_record{software_name}) if ($hotfix_record{operating_system} eq 'win2k'); push (@hotfix_w2003, $hotfix_record{software_name}) if ($hotfix_record{operating_system} eq 'w2003'); push (@hotfix_winxp, $hotfix_record{software_name}) } $db->Close(); #** Compare the installed arrays to the database arrays and make lists of #** hotfixes to be installed. @ready_nt4wk = Check_Array (@installed_nt4wk , @hotfix_nt4wk); @ready_nt4sv = Check_Array (@installed_nt4sv , @hotfix_nt4sv); @ready_win2k = Check_Array (@installed_win2k , @hotfix_win2k); @ready_w2003 = Check_Array (@installed_w2003 , @hotfix_w2003); @ready_winxp = Check_Array (@installed_winxp , @hotfix_winxp); #** Loop through arrays and install hotfix files per os. foreach my $hotfix (@ready_nt4wk){Add_Hotfix ($hotfix,$valid_os[0])} foreach my $hotfix (@ready_nt4sv){Add_Hotfix ($hotfix,$valid_os[1])} foreach my $hotfix (@ready_win2k){Add_Hotfix ($hotfix,$valid_os[2])} foreach my $hotfix (@ready_winxp){Add_Hotfix ($hotfix,$valid_os[3])} foreach my $hotfix (@ready_w2003){Add_Hotfix ($hotfix,$valid_os[4])}