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.

The Error

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.

The Code

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.

"No matter where you go, there you are." BB

In reply to Self Extracting Cabinet Files in Perl by Ninthwave

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.