Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23305

How to pass arguments containing parentheses to aws ecs execute-command using python subprocess.run?

$
0
0

Goal: Use the aws cli in a subprocess.run call to execute a command in a container of a running task.
Example Usage:

task_arn = 'a_task_arn'arg = event = {'something': 'that contains ( )'}# Attempt 1: json stringarg = json.dumps(arg)subprocess_cmd = 'aws ecs execute-command --command "python -m task.function {arg}" --interactive --task {task_arn} --container Container'subprocess.run(subprocess_cmd, shell=True# Attempt 2: encoded json stringarg = json.dumps(arg).encode('utf-8')subprocess_cmd = 'aws ecs execute-command --command "python -m task.function {arg}" --interactive --task {task_arn} --container Container'subprocess.run(subprocess_cmd, shell=True

Encountered Error: /bin/sh: 1: Syntax error: "(" unexpected

I am trying to use the cli through a subprocess.run call instead of using the boto3 execute_command because


Viewing all articles
Browse latest Browse all 23305

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>