python - powershell script failed to run from heat template because of parse error -


i have powershell script search string, , script worked when run powershell command prompt directly, failed run when put in userdata of heat template: script is:

$regex = [regex]"(?<=\>)(\d+)(.*)snapshot(?=\/\<)" $allsnapshot=$regex.matches($testcode1) | % { $_.matches } | % { $_.value }  |get-unique |sort -descending 

the error is:

execute_user_data_script c:\program files (x86)\cloudbase solutions\cloudbase-init\python27\lib\site-packages\cloudbaseinit\plugins\windows\userdatautils.py:58 2015-04-25 12:11:45.140 1796 debug cloudbaseinit.plugins.windows.userdatautils [-] user_data stderr: term '?<=\>' not recognized name of cmdlet, function, script file, or operable program. check spelling of name, or if path included, verify path correct , try again.  @ c:\users\cloudbase-init\appdata\local\temp\835603b2-b3dc-4a9b-a156-029c75322  a8f.ps1:26 char:24  + $regex = [regex]"(?<=\> <<<< )(\d+)(.*)snapshot(?=\/\<)"      + categoryinfo          : objectnotfound: (?<=\>:string) [], commandnotfou      ndexception      + fullyqualifiederrorid : commandnotfoundexception 

i think it's parse issue. don't know how fix it. how can avoid python parse it?

i struggled on several days. appreciate advice.

it's possible python might not allow use powershell v3 object casting, you're doing when implicitly type variable, [xml](get-content .\somexml.xml) or in case, regex.

i'd recommend trying tried , true powershell v1 , object casting syntax, looks this:

$regex = new-object -typename regex -argumentlist "(?<=\>)(\d+)(.*)snapshot(?=\/\<)"  

i've run problems experiencing when port tools newer versions of powershell , wmf older versions. errors can indecipherable!

if doesn't help, please let me know , can try work out solution together.


try use here-string, here example of one:

"""this multiline string  more 1 line  in source code.""" 

as seen here: how write string literals in python without having escape them?.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -