Ninthwave has asked for the wisdom of the Perl Monks concerning the following question:
Does anyone know where I can find a utility to read these wonderful little things from Microsoft. I can read them in WinZip and thought well I could use Archive::Zip to open them and get the information out of the file. But this errors when trying to open the file.
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(0x2f48 +95c)','c:/ Patch_Adams/Patches/Windows2000-KB824146-x86-ENU.exe') called at C:\Pa +tch_Adams\ scripts\hotfix_update.pl line 83 main::Add_Hotfix('Windows2000-KB824146-x86-ENU.exe','win2k') c +alled 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 , @installe +d_w2003 , @installed_winxp); my (@hotfix_nt4wk , @hotfix_nt4sv , @hotfix_win2k , @hotfix_w2003 , @h +otfix_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 th +is #** 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 + $l +ength_w2003 + $length_winxp; die "No hotfix files are installed in directory $PATCH_PATH\n" if ($le +ngth_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_re +cord{operating_system} eq 'nt4wk'); push (@hotfix_nt4sv, $hotfix_record{software_name}) if ($hotfix_re +cord{operating_system} eq 'nt4sv'); push (@hotfix_win2k, $hotfix_record{software_name}) if ($hotfix_re +cord{operating_system} eq 'win2k'); push (@hotfix_w2003, $hotfix_record{software_name}) if ($hotfix_re +cord{operating_system} eq 'w2003'); push (@hotfix_winxp, $hotfix_record{software_name}) } $db->Close(); #** Compare the installed arrays to the database arrays and make list +s 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])}
Does anyone have any experience playing with these type of files or know of a module or utility that can handle this type of data. I don't want to reinvent the wheel but I am having a hard time finding information on the format of the files.
Yes I know I need to clean up most of the code but it processes the data correctly, which is my concern for now, it just will not open the .exe. For a note this is the Microsoft Hotfix files. I want to place them in a directory as approved hot fixes and read the update.ver exe which lists the files updated. I would parse this into an xml document with the file version numbers. That way I can automatically create records for my scanner to compare instead of manually entering the information.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Self Extracting Cabinet Files in Perl
by Limbic~Region (Chancellor) on Nov 12, 2003 at 18:30 UTC | |
by Ninthwave (Chaplain) on Nov 12, 2003 at 21:07 UTC | |
|
Re: Self Extracting Cabinet Files in Perl
by jmanning2k (Pilgrim) on Nov 12, 2003 at 21:29 UTC | |
by Ninthwave (Chaplain) on Nov 12, 2003 at 22:05 UTC | |
by Ninthwave (Chaplain) on Nov 13, 2003 at 12:07 UTC | |
|
Re: Self Extracting Cabinet Files in Perl
by graff (Chancellor) on Nov 17, 2003 at 04:17 UTC |