Replace in Files not acting as expected

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
KenJFried
Posts: 2
Joined: Wed Feb 22, 2017 10:49 am

Replace in Files not acting as expected

Post by KenJFried » Fri Feb 24, 2017 11:04 am

Product, version and build: Primal Script 2017, Version 7.3.99
(*** Please do not write "latest" as a version, specify a version number ***)
32 or 64 bit version of product: 64 bit
Operating system: Windows 7
32 or 64 bit OS: 64 bit

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

I'll admit I'm a new user but I have done my level best at finding this in the documentation and forum posts for what I think should be the a simple task.

I am trying to use the Replace in Files function for the second use item for this product. For my first use item I ran a Find in Files for the following entry in xml: //kmhpsftpreppa20/SFTP/sftp root/
This was done in a folder with many subfolders and it found 69 instances in various files in folders and various lines in the folders

When I try to run the Replace in Files item to replace the above text with the following text: ${TidalVar_//KMHPSFTPREPPA20/SFTP/}
the result gives me a listing that all 69 instances are replaced.

When validating the results I get the following:
the first instance of the find / replace in a file give me this, which is correct:
--source="${TidalVar_//KMHPSFTPREPPA20/SFTP/}statepa/47TPL766"

The next two instances in the same file give me this, which is not correct, it's replacing two characters further to the left:
--sourc"${TidalVar_//KMHPSFTPREPPA20/SFTP/}t/statepa/57TPL766"
--sou"${TidalVar_//KMHPSFTPREPPA20/SFTP/}oot/statepa/37TPL766"

This appears to happen in any file where there is more than one occurrence of the replace. The first occurrence is always correct but subsequent occurrences are off two characters to the left. I can, of course, manually fix these but it seems like this should work correctly. The file replacements are not the first lines in the xml, often times 40-70 lines deep (there are repetitive xml tasks in many of these files). I haven't been able to find any special characters or other issues to date and thought I would ask if you had run into this before or had an idea.

I have attached one result file which is where the example above came from and the original source file from before the replace.

Thank you.
Attachments
070_TTK_KMHP_MEM_TPLFilestodownload - Source.xml
(15.81 KiB) Downloaded 201 times
070_TTK_KMHP_MEM_TPLFilestodownload - Result.xml
(16 KiB) Downloaded 83 times

User avatar
Alexander Riedel
Posts: 7098
Joined: Tue May 29, 2007 4:43 pm

Re: Replace in Files not acting as expected

Post by Alexander Riedel » Fri Feb 24, 2017 11:17 am

Ok, thank you for the sample file. We will look into it right away.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
KenJFried
Posts: 2
Joined: Wed Feb 22, 2017 10:49 am

Re: Replace in Files not acting as expected

Post by KenJFried » Tue Mar 14, 2017 3:19 pm

Hi - Is there any update to this issue? Thank you.

User avatar
Alexander Riedel
Posts: 7098
Joined: Tue May 29, 2007 4:43 pm

Re: Replace in Files not acting as expected

Post by Alexander Riedel » Tue Mar 14, 2017 9:38 pm

Yes, it has been resolved in the last update. See log :

7.3.100
Fix: Find and replace in files can place replacements incorrectly
Add: Packager Option - Do not execute if Script Block logging is enabled.
Add: Packager Option - Disable Script Block logging while running (Requires elevated admin privileges).
Alexander Riedel
SAPIEN Technologies, Inc.