I am after some best practice advise relating to reading a text file, replacing some information and then writing the data to a new file.
As an example, my source file contains:
I need to change the line:
com.iplanet.services.debug.level=message
com.iplanet.services.debug.directory=c:/Path/To/Debug
com.iplanet.am.naming.url=https://naming.com/url
com.iplanet.am.naming.ignoreNamingService=true
com.iplanet.am.server.protocol=https
com.iplanet.am.server.host=naming.com
com.iplanet.am.server.port=443
com.iplanet.am.notification.url=http://localserver.com:3700/LocalService/service.svc
com.iplanet.am.cookie.name=iPlanetDirectoryPro
com.iplanet.am.cookie.encode=true
com.iplanet.am.jssproxy.trustAllServerCerts=true
com.iplanet.am.version=6.1
com.iplanet.security.SecureRandomFactoryImpl=com.iplanet.am.util.SecureRandomFactoryImpl
com.iplanet.security.SSLSocketFactoryImpl=netscape.ldap.factory.JSSESocketFactory
com.iplanet.security.encryptor=com.iplanet.services.util.JCEEncryption
com.sun.identity.webcontainer=IAS7.0
to becom.iplanet.services.debug.directory=c:/Path/To/Debug
andcom.iplanet.services.debug.directory=c:/NewPath/Somewhere/Else
tocom.iplanet.am.notification.url=http://localserver.com:3700/LocalService/service.svc
I originally started of with something like this:com.iplanet.am.notification.url=http://localserver.com:3700/NewName/service.svc
However this resulted in some weird results (the target file only contained the first line of the source file)
ClearErrors
FileOpen $0 "${sourcefile}" r
FileRead $0 $1
FileClose $0
${WordReplace} $1 "c:/Path/To/Debug" "c:/NewPath/Somewhere/Else" "E+" $R0
${WordReplace} $R0 "/LocalService/" "/NewName/" "E+" $R1
ClearErrors
FileOpen $0 "${targetfile}" w
FileWrite $0 $1
FileClose $0
So after hunting around the wiki I haven't found a definitive way of doing this. So can anybody point me in the right direction.
EDIT : After some further hunting, I came across the following:
Which seems to work. All I need to do is copy the source for to the target location and then use these functions to make the edits.