cl-test.py 524 B

12345678910111213141516171819202122232425
  1. import subprocess
  2. import json
  3. import sys
  4. cmd='aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=RunInstances --max-results 20 --region us-east-1'
  5. cmds=cmd.split(' ')
  6. cl=subprocess.run(cmds,text=True, capture_output=True)
  7. clstr=str(cl)
  8. lines=clstr.split('\n')
  9. lst=[]
  10. for l in lines:
  11. # print(l)
  12. if '"AccessKeyId":' in l:
  13. lst.append(l)
  14. if '"EventName":' in l:
  15. lst.append(l)
  16. print(lst)
  17. # print(l)
  18. # sys.exit()
  19. #js=json.loads(str(cl))
  20. #print(js)