last updated at 01 Sep, 2005 06:23 (1 times)
This may work.... I'm assuming all of the systems have REXXUTIL installed.
Be sure to test it yourself before distributing!
(As written the script is case sensitive, so it will happily add an existing path again if the case is different.)
/*REXX script to add (something) to the libpath line in <sysdrive>:\config.sys*/
call rxFuncAdd "SysLoadFuncs", "REXXUTIL", "SysLoadFuncs"
Call SysLoadFuncs
/*Text to add is: (something)*/
addtext="P:\acrobat3\acroread;"
/*Find boot drive*/
signal on Syntax name GetOS2BootDrive1 /* install a local error handler */
boot_drive = ''
boot_drive = SysBootDrive()
/*Make temporary file*/
tmp= VALUE( "TMP",, "os2environment" )
tempfile=systempfilename(tmp||"\config.t???" )
modified=0 /*The config.sys has not yet been modified.*/
/*Read lines in config.sys, writing them to a temporary file*/
configsys= boot_drive||"\config.sys"
do while lines(configsys)>0
line=linein(configsys)
parse var line begg "=" endd
select
when strip(translate(begg))="LIBPATH" then do
/*Find out whether libpath line ends in ";" and add as necessary*/
if right(strip(endd),1)<>";" then endd=strip(endd) || ";"
/*Add (something) to libpath if it doesn't yet exist*/
if pos(addtext,endd)=0 then endd=endd || addtext
else signal cleanup
/*Find out whether libpath line ends in ";" and add as necessary*/
if right(strip(endd),1)<>";" then endd=strip(endd) || ";"
rc=lineout(tempfile,begg || "=" || endd)
end /* do */
otherwise rc=lineout(tempfile,line) /*Write rest of config.sys to temporary file*/
end /* select */
end /* do */
/*If the above ran through, then config.sys has been modified.*/
modified=1
/*Close config.sys and tempfile*/
rc=stream(configsys,"C","CLOSE")
rc=stream(tempfile,"C","CLOSE")
/*Find last existing config.Tnn file (by number)*/
t=0
do i=1 to 99
dd=right(i,2,0)
temp.i=stream(boot_drive || '\CONFIG.T' || dd, 'c', 'QUERY EXIST' )
end /* do */
do i=99 to 0 by -1
if temp.i<>"" then signal nextt
end /* do */
nextt:
tbackup=boot_drive || "\config.t" || right(i+1,2,0)
/*Copy config.sys to config.Tnn+1 */
"copy " configsys tbackup
rc=stream(configsys,"C","CLOSE")
rc=stream(tbackup,"C","CLOSE")
/*Copy temporary file to config.sys*/
if translate(stream(tbackup, 'c', 'QUERY EXIST' ))=translate(tbackup)
then "copy" tempfile boot_drive || "\config.sys"
cleanup: /*Delete temporary file*/
rc=stream(tempfile,"C","CLOSE")
call SysDestroyObject tempfile
select
when modified=0 then do
say "Config.sys has NOT been modified"
say "because LIBPATH already contained '" || addtext || "'."
end /* do */
when modified=1 then do
say "Config.sys has been modified."
say "'" || addtext || "' was added to the LIBPATH."
say "The old config.sys has been backed up as '" || tbackup "'."
end /* do */
otherwise do
say "This script has a bug."
say "Please contact the system administrator."
end
end /* select */
exit
GetOS2BootDrive1:
ok=0
if boot_drive = '' then
do
path=translate(VALUE( "PATH",, "os2environment" ) )
parse var path begg "\OS2\SYSTEM;" endd
boot_drive=right(begg,2)
end
if stream(boot_drive || '\CONFIG.SYS', 'c', 'QUERY EXIST' )=boot_drive||"\CONFIG.SYS" then ok=1
if ok=1 then return boot_drive
else do
say "Couldn't positively identify boot drive."
say "so your system has NOT been modified."
say "Contact your friendly administrator."
say "(Press ENTER to quit.)"
end /* do */
pull
exit