I am trying to capture the output of an aws ec2 delete-snapshot
in a Bash script command but I cannot get anything to capture the output. I have tried result=$(command)
, result=`command`
etc. but when I try to echo $result
there is nothing there.
Here is some example output.
root@host:~# aws ec2 delete-snapshot --snapshot-id vid --output json>test
A client error (InvalidParameterValue) occurred when calling the DeleteSnapshot operation: Value (vid) for parameter snapshotId is invalid. Expected: 'snap-...'.
root@host:~# aws ec2 delete-snapshot --snapshot-id vid>test
A client error (InvalidParameterValue) occurred when calling the DeleteSnapshot operation: Value (vid) for parameter snapshotId is invalid. Expected: 'snap-...'.
root@host:~# cat test
root@host:~# testing=$(aws ec2 delete-snapshot --snapshot-id vid)
A client error (InvalidParameterValue) occurred when calling the DeleteSnapshot operation: Value (vid) for parameter snapshotId is invalid. Expected: 'snap-...'.
root@host:~# echo $testing
root@host:~#
I need to automate creation and deletion of snapshots, but I can't capture the output.
Has anyone else ran into this issue?