VMware Cloud Community
AnonymousDefaul
Enthusiast
Enthusiast

Read file without replacing ${xxx} as variable

Hello, I would like to ask if it is possible to read the content from cmake file without replacing ${xxx} as a variable? I need to do multiline substitution in cmake file, so I use readFile option, then setVariableFromRegularExpression and then writeFile option. But when I read the content of file, it has all variables ${xxx} replaced to ***unkown variable xxx***. Could you please add some solution for this problem?



Thank you.


Have a nice day,



Michaela Lukasova


Codasip s.r.o


lukasova@codasip.com

Labels (1)
7 Replies
AnonymousDefaul
Enthusiast
Enthusiast

Hi Michaela,

We are sorry for the late reply. We have been facing some spam issues and we missed your post.

A possible way of doing this is extracting just the exact text you want to replace using <setInstallerVariableFromRegEx?, then apply a <substitute> action in  or ' exact or '  mode. Please find below an example:

 <readFile>
     <name>file_content</name>
     <path>${file}</path>
</readFile>
<setInstallerVariableFromRegEx>
     <name>text_to_substitute</name>
     <pattern>^.*?(${pattern}).*$</pattern>
     <substitution> or  or 1</substitution>
     <text>${file_content}</text>
</setInstallerVariableFromRegEx>
<substitute>
     <files>${file}</files>
     <type>exact</type>
     <substitutionList>
         <substitution>
             <pattern>${text_to_substitute}</pattern>
             <value>${substitution}</value>
         </substitution>
     </substitutionList>
</substitute>

Please note this won't work if the selected text includes a variable with ${xxx} syntax.

Would the above work for you?

Looking forward to your feedback,
Alejandro

0 Kudos
AnonymousDefaul
Enthusiast
Enthusiast

Hello,
I need to do multiline substitution. It does not seem that the last step with substitution works.
I tried to use this solution https://support.bitrock.com/hc/en-us/community/posts/115002745069-Can-I-perform-a-Multi-line-regex-t...

but the variables in cmake with ${xxx} convention were replaced with ***unknown variable xxx***

Thank you, Michaela

0 Kudos
AnonymousDefaul
Enthusiast
Enthusiast

Hi Mlukasova,

Could you check if the workaround described in the following post would work for you?

https://support.bitrock.com/hc/en-us/community/posts/115002029705-How-do-I-read-and-display-a-shell-...

Best regards,

Michiel

0 Kudos
AnonymousDefaul
Enthusiast
Enthusiast

Hi,
no it will not help. I will try to explain it one more time.

 

I have cmake file, which contains about 5 lines that i have to replace with one line. It also contains lot of variables like ${SIM_DIR} etc. I think i now have only one solution - i read the file with custom readFileEscapeVars  , then I have to  setInstalerVariableFromRegex but it will  replace these ${variables} and if not, the writeFile will. So i think i need some custom function to set variable from regex without replacing ${variables} and also writeFile without replacing ${variables}. Do you think it is the only way? And if it is, is it possible that you create some functions like this?

 

Thank you, 
Michaela

0 Kudos
AnonymousDefaul
Enthusiast
Enthusiast

Hi Michaela,

Please accept my apologies for the delay in my reply, we are currently investigating a solution for this. I will contact you as soon as possible with further information.

Best regards,

Michiel

0 Kudos
AnonymousDefaul
Enthusiast
Enthusiast

I have the same issue.

Any updates?

0 Kudos
michiel_dhont
Enthusiast
Enthusiast

Hi Andrei,

Unfortunately this is still not supported. Perhaps a workaround could be to replace those variables using a custom script and run that with runProgram. Could you give more information about your project?

Regards,

Michiel

0 Kudos