-1

I'm trying typing

command = "aws ec2 describe-instances --query "Reservations[*].Instances[].{ instance_id: InstanceId, type: InstanceType, stats: State.Name, disks: BlockDeviceMappings[*].Ebs.VolumeId, p_ip: NetworkInterfaces[*].PrivateIpAddresses[].PrivateIpAddress, name: Tags[?Key == `Name`].Value, cpu: CpuOptions.CoreCount, platform: PlatformDetails}" > output.json"
os.system(command)

I got an error when debbuging. Is there anyone correct this syntax.

2
  • Either: a) replace outer " with """ (or ') or b) replace inner " with \"
    – matszwecja
    Sep 19, 2022 at 12:50
  • You should add the error message
    – Jens
    Sep 19, 2022 at 12:51

1 Answer 1

0

You have to escape the double quotes:

command = "aws ec2 describe-instances --query \"Reservations[*].Instances[].{ instance_id: InstanceId, type: InstanceType, stats: State.Name, disks: BlockDeviceMappings[*].Ebs.VolumeId, p_ip: NetworkInterfaces[*].PrivateIpAddresses[].PrivateIpAddress, name: Tags[?Key == `Name`].Value, cpu: CpuOptions.CoreCount, platform: PlatformDetails}\" > out22.json"
os.system(command)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.