diff --git a/contents/common.py b/contents/common.py index ae69859..b0e7d7e 100644 --- a/contents/common.py +++ b/contents/common.py @@ -25,3 +25,11 @@ def get_file(destination): return filename + +def replace_single_quotes_format(command): + command = command + " " + command = re.sub(r'\s(\')',' \"', command) + command = re.sub(r'(\')\s','\" ', command) + command = re.sub(r'\'("\'")\'', "\'", command) + + return command diff --git a/contents/winrm-exec.py b/contents/winrm-exec.py index 480767c..f871894 100644 --- a/contents/winrm-exec.py +++ b/contents/winrm-exec.py @@ -10,6 +10,7 @@ import logging import colored_formatter import kerberosauth +import common from colored_formatter import ColoredFormatter @@ -157,7 +158,10 @@ def filter(self, record): if "RD_CONFIG_OPERATIONTIMEOUT" in os.environ: operationtimeout = os.getenv("RD_CONFIG_OPERATIONTIMEOUT") -exec_command = os.getenv("RD_EXEC_COMMAND") +exec_command = os.getenv("RD_EXEC_COMMAND") + +if "cmd" in shell: + exec_command = common.replace_single_quotes_format(exec_command) endpoint=transport+'://'+args.hostname+':'+port