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 LICENSE NUMBERS, ACTIVATION 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.
This topic is 7 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
KenJFried
Posts: 2
Last visit: Tue Oct 30, 2018 9:20 am

Replace in Files not acting as expected

Post by KenJFried »

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 309 times
070_TTK_KMHP_MEM_TPLFilestodownload - Result.xml
(16 KiB) Downloaded 198 times
User avatar
Alexander Riedel
Posts: 8488
Last visit: Tue Apr 16, 2024 8:42 am
Answers: 20
Been upvoted: 37 times

Re: Replace in Files not acting as expected

Post by Alexander Riedel »

Ok, thank you for the sample file. We will look into it right away.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
KenJFried
Posts: 2
Last visit: Tue Oct 30, 2018 9:20 am

Re: Replace in Files not acting as expected

Post by KenJFried »

Hi - Is there any update to this issue? Thank you.
User avatar
Alexander Riedel
Posts: 8488
Last visit: Tue Apr 16, 2024 8:42 am
Answers: 20
Been upvoted: 37 times

Re: Replace in Files not acting as expected

Post by Alexander Riedel »

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.
This topic is 7 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.