$!------------------------------------------------------------------------ $! SHOW_PATCHES.COM $! This program will download the list of currently available patches $! from the Compaq/HP website. It will then get a list of the installed $! patches on your system. It compares these two lists to generate a $! report that shows what patches are available, what patches you have $! installed, the versions and indicates whether a newer patch is $! available. $! $! If you have a system that does not have FTP access to the Internet, you $! can pass P1 as DOWNLOAD, P2 as the version of VMS and P3 as the architecture $! and the list of patches will just be downloaded. The list will be stored $! in a file called vmsversion_PATCHES.TXT. Transfer this file to the appropriate $! system and run this program with P1 set to FILE and P2 set to the version. $! $! The architecture should be: vax, alpha or ipf. The default is alpha $! $! The version that is passed in should be in the format VM.m-p. $! $! If you want to limit the display to just the patches that need to be $! installed, pass in LIMIT as the final parameter. This will normally $! be P1 unless you are using DOWNLOAD or FILE in which case it will be P3. $! $!------------------------------------------------------------------------ $! Update these parameters as necessary. The server and the path should $! only change if HPQ changes these. The FILEINDEX will only need to be $! changed if you generate the list of patches through some other means $! besides this program. $ username = "anonymous" $ password = "anonymous@nowhere.com" $ ftpserver = "ftp.itrc.hp.com" $ ftppath = "/openvms_patches/" $ passiveon = "TRUE" $ fileindex = 8 $! $ if p3 .nes. "" $ then arch = f$edit( p3, "LOWERCASE" ) $ else arch = f$getsyi( "ARCH_TYPE" ) $ endif $ if arch .eq. 1 then arch = "vax" $ if arch .eq. 2 then arch = "alpha" $ if arch .eq. 3 then arch = "ipf" $! $! Set up the differences between the architectures $ patchext = "" $ patchpref = "" $ if arch .eqs. "vax" $ then patchext = "A-DCX_VAXEXE" $ patchpref = "VAX" $ endif $ if arch .eqs. "alpha" $ then patchext = "PCSI-DCX_AXPEXE" $ patchpref = "VMS" $ endif $! $ ftppath = "''ftppath'''arch'" $! $! Get the current PID for generating temporary files $ pid = f$getjpi( "", "PID" ) $! $ show_only_upgrade = "FALSE" $ just_download = "FALSE" $ use_file = "FALSE" $! $! We just want to download the file $ if f$edit( p1, "UPCASE,TRIM" ) .eqs. "DOWNLOAD" $ then just_download = "TRUE" $ vmsversion = "V" + ( f$edit( p2, "UPCASE,TRIM" ) - "V" ) $ goto do_ftp $ endif $! We want to use a downloaded file $ if f$edit( p1, "UPCASE,TRIM" ) .eqs. "FILE" $ then use_file = "TRUE" $ vmsversion = "V" + ( f$edit( p2, "UPCASE,TRIM" ) - "V" - "." - "-" ) $ endif $! Just show what needs an update $ if f$edit( p1, "UPCASE,TRIM" ) .eqs. "LIMIT" then show_only_upgrade = "TRUE" $ if f$edit( p3, "UPCASE,TRIM" ) .eqs. "LIMIT" then show_only_upgrade = "TRUE" $! $end_options: $! $! Generate a list of all install patches on this system $ define sys$output show_patches1.'pid' $ product show product vms/full $ deassign sys$output $! $! Read through the list and create symbols for installed patches $ open/read infile show_patches1.'pid' $find_product_loop: $ read/end=done infile aline $! If the line does not start with PRODUCT, then we have not found the $! beginning of the section. $ if f$extract( 0, 7, aline ) .nes. "PRODUCT" then goto find_product_loop $! $! We found the beginning of a PRODUCT section. Now get the patches. $ read/end=done infile aline $ read/end=done infile aline $ product = f$edit( f$extract( 0, 35, aline ), "TRIM" ) $patch_loop: $ patch = f$extract( 61, 35, aline ) $! $! We have all of the patches $ if f$extract( 0, 5, patch ) .eqs. "-----" then goto end_patch_loop $! $! Parse out the patch name and version $ patchname = f$element( 2, " ", patch ) $ patchver = f$element( 3, " ", patch ) $! $! Check if we have this patch already. If so, see if we already have a $! newer version and update the stored version. $ if f$type( installed'patchname' ) .eqs. "" $ then installed'patchname' = "''patchver'" $ else if patchver .ges. installed'patchname' $ then installed'patchename' = "''patchver'" $ endif $ endif $! $! Read the next line $ read/end=done infile aline $! $! Loop to identify the next patch $ goto patch_loop $! $end_patch_loop: $! $! Find the next product $ goto find_product_loop $! $done: $! $! We have all of the installed patches $ close infile $! $! Get the version of VMS so we get the correct list of available patches $ if .not. use_file then vmsversion = "V" + ( f$getsyi( "VERSION" ) - "V" ) $! $do_ftp: $! $! If we downloaded a file, skip the FTP $ if use_file then goto finish_ftp $! $! Create an FTP script $ open/write outfile show_patches2.'pid' $ if passiveon then write outfile "passive on" $ write outfile "cd ''ftppath'" $ write outfile "cd ''vmsversion'" $ write outfile "dir" $ write outfile "quit" $ close outfile $! $! Setup the appropriate FTP command qualifiers $ ftpqual = "/input=" $ if f$trnlnm( "MULTINET" ) .nes. "" then ftpqual = "/take_file=" $! $! Perform the FTP to get the list of available patches $ define sys$output show_patches3.'pid' $ ftp 'ftpserver'/user="''username'"/password="''password'"'ftpqual'show_patches2.'pid' $ deassign sys$output $! $finish_ftp: $! $! If we are just downloading the file, then rename it and cleanup $ if just_download $ then vmsversion = vmsversion - "." - "-" $ rename show_patches3.'pid' 'vmsversion'_patches.txt $ goto cleanup $ endif $! $! If we are using a specified file, then check for the file and rename it $ if use_file $ then if f$search( "''vmsversion'_patches.txt" ) .nes. "" $ then copy 'vmsversion'_patches.txt show_patches3.'pid' $ else write sys$output "Could not find ''vmsversion'_patches.txt" $ goto cleanup $ endif $ endif $! $! Write the header for our report $ write sys$output f$fao( "!25AS!10AS!10AS", "Patch", "Avail", "Current", "Update" ) $! $! Read through the FTP output and generate the report $ open/read infile show_patches3.'pid' $! $show_avail_loop: $ matchver = "" $ upgrade = "" $ read/end=avail_done infile aline $ aline = f$edit( aline, "COMPRESS,TRIM" ) $ filename = f$element( fileindex, " ", aline ) $! Is the file a patch file $ filename = f$edit( filename, "UPCASE" ) $ if f$element( 1, ".", filename ) .nes. patchext then goto show_avail_loop $ if arch .eqs. "vax" then patchname = f$element( 0, ".", filename ) $ if arch .eqs. "alpha" then patchname = f$element( 0, "-", filename ) $! Does the patch name start correctly $ if f$extract( 0, 3, patchname ) .nes. patchpref then goto show_avail_loop $ if arch .eqs. "vax" then patchname = patchname - "VAX" $! Get the patch version and format it $ if arch .eqs. "vax" $ then patchver = f$element( 0, "_", patchname ) $vax_patch_version_find: $ if f$length( patchver ) .gt. 0 $ then if f$type( patchver ) .nes. "INTEGER" $ then patchver = patchver - f$extract( 0, 1, patchver ) $ goto vax_patch_version_find $ endif $ patchver = f$fao( "V!UB.0", patchver * 1 ) $ endif $ endif $ if arch .eqs. "alpha" $ then patchver = f$element( 1, "-", f$element( 0, ".", filename ) ) $ patchver = f$fao("V!UB.!UB", f$extract( 1, 2, patchver)*1,f$extract( 3, 2, patchver) * 1) $ endif $! If the patch is installed, get the version that is installed $ if f$type( installed'patchname' ) .nes. "" then matchver = installed'patchname' $! If we do not have the most current, indicate in the report $ if patchver .nes. matchver then upgrade = "*" $! Write out the patch information $ if show_only_upgrade .and. upgrade .nes. "*" then goto skip_write $ write sys$output f$fao( "!25AS!10AS!10AS!1AS", patchname, patchver, matchver, upgrade ) $skip_write: $! $! Loop back for the next available patch $ goto show_avail_loop $! $avail_done: $! $! We are done. Now we need to cleanup. $ close infile $! $cleanup: $! $ if f$search( "show_patches1.''pid'" ) .nes. "" then delete/nolog show_patches1.'pid'; $ if f$search( "show_patches2.''pid'" ) .nes. "" then delete/nolog show_patches2.'pid'; $ if f$search( "show_patches3.''pid'" ) .nes. "" then delete/nolog show_patches3.'pid'; $! $ exit