Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for rxsyslvl.cmd

(view source code of rxsyslvl.cmd as plain text)

  1. /* Determine OS/2 version and fixpack level       */
  2. /* Original Rexx script by Mike Ruskai            */
  3. /* Adapted to [a] include international versions, */ 
  4. /* and [b] add return codes by Rob van der Woude  */
  5.  
  6. /* Check for command line parameters */
  7. parse upper arg param dummy
  8. if param <> "" then do
  9. 	if dummy <> "" then call Syntax
  10. 	parse value param with dummy"/"option
  11. 	if dummy <> "" then call Syntax
  12. 	if option <> "" then option = left( option, 1 )
  13. 	select
  14. 		when option = "B" then returncode = "OS2VER"
  15. 		when option = "F" then returncode = "FPLEVEL"
  16. 		when option = "O" then returncode = "OS2VER"
  17. 		otherwise call Syntax
  18. 	end
  19. end
  20.  
  21. /* Initialize RexxUtil */
  22. if RxFuncQuery( "SysLoadFuncs" ) <> 0 then do
  23. 	call RxFuncAdd "SysLoadFuncs","RexxUtil","SysLoadFuncs"
  24. 	call SysLoadFuncs
  25. end
  26.  
  27. /* Check Rexx version and use the appropriate */
  28. /* method to determine the boot drive         */
  29. parse version verstring
  30. if word( verstring , 1 ) = "OBJREXX" then do
  31. 	bootdrive = SysBootDrive( )
  32. end
  33. else do
  34. 	path = value( "PATH", , "OS2ENVIRONMENT" )
  35. 	parse upper value path with ":\OS2\SYSTEM" -1 bootdrive +2
  36. 	if path = "" | bootdrive = "" then do
  37. 		say
  38. 		say "Unable to determine boot drive"
  39. 		exit 9
  40. 	end
  41. end
  42.  
  43. /* Read SYSLEVEL.OS2 and extract version strings */
  44. syslevel = bootdrive||"\OS2\INSTALL\SYSLEVEL.OS2"
  45. check = stream( syslevel, "c", "open read" )
  46. if check = "" then do
  47. 	say
  48. 	say "Unable to open SYSLEVEL.OS2"
  49. 	exit 8
  50. end
  51. leveldata = charin( syslevel, , chars( syslevel ) )
  52. call stream syslevel, "c", "close"
  53.  
  54. /* Check and format version strings */
  55. parse var leveldata "XR" fplevel "_XR" os2ver "_IBM"
  56. fplevel = right( fplevel, 3 )
  57. os2ver  = right( os2ver, 4 ) / 1000
  58. if strip( fplevel ) = "" | datatype( fplevel, "W" ) = 0 |,
  59.    strip( os2ver ) = "" | datatype( os2ver, "W" ) = 0 then do
  60. 	say
  61.         say "Unable to determine version and fixpack level"
  62. 	exit 7
  63. end
  64.  
  65. /* Read SYSLEVEL.FPK and extract fixpack version */
  66. syslevel = bootdrive||"\OS2\INSTALL\SYSLEVEL.FPK"
  67. check = stream( syslevel, "c", "open read" )
  68. if check <> "" then do
  69. 	leveldata = charin( syslevel, , chars( syslevel ) )
  70. 	parse var leveldata "XR" fplevel "_XR"
  71. 	fplevel = right( fplevel, 3 )
  72. 	if strip( fplevel ) = "" | datatype( fplevel, "W" ) = 0 then do
  73. 		say
  74. 		say "Unable to determine fixpack level"
  75. 	end
  76. end
  77. call stream syslevel, "c", "close"
  78.  
  79. /* Format fixpack version string */
  80. fplevel = format( fplevel, , 0 )
  81.  
  82. /* Display results */
  83. say "OS/2 base version:  "||os2ver
  84. say "OS/2 fixpack level: "||fplevel
  85.  
  86. /* Quit */
  87. if returncode = "OS2VER"  then exit os2ver
  88. if returncode = "FPLEVEL" then exit fplevel
  89. exit 0
  90.  
  91.  
  92. Syntax:
  93. 	say
  94. 	say "RxSysLvl"
  95. 	say "Returns OS/2 Version and FixPack Level"
  96. 	say
  97. 	say "Usage:  RXSYSLVL  [ /Base_version | /Fixpack_level ]"
  98. 	say
  99. 	say "   /B                     return code = OS/2 Major Version Number"
  100. 	say "   /F                     return code = FixPack Level"
  101. 	say "   blank (none)           return code = 0"
  102. 	say "   any other parameter    return code = 255"
  103. 	exit 255
  104. return
  105.  

page last modified: 2024-04-16; loaded in 0.0115 seconds