Guest User

Untitled

a guest
Feb 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ###################################
  4. # USAGE:
  5. # ./subs-export.csv.bash <ORG NAME>
  6. #
  7. # NOTE: If you run this without the
  8. # organization name as a parameter
  9. # it will return 0 results.
  10. ###################################
  11.  
  12.  
  13. echo "Name,Organization,Subscriptions"
  14. echo "SELECT '\"' || f.element || '\"','\"' || o.displayname || '\"','\"\"\"'||e.quantity||'|'||p.productid||'|'||p.productname||'|'||p.contractnumber||'|'||p.accountnumber||'\"\"\"' FROM
  15. cp_consumer c,
  16. cp_owner o,
  17. cp_pool p,
  18. cp_entitlement e,
  19. cp_consumer_facts f
  20. WHERE c.owner_id = o.id AND
  21. e.consumer_id = c.id AND
  22. p.id = e.pool_id AND
  23. f.cp_consumer_id = c.id AND
  24. f.mapkey = 'network.fqdn' AND
  25. o.displayname = '$1';" | sudo -u postgres psql -d candlepin -t -A -F',' | awk -F '"""' '{if ($2!="") print }' -
Add Comment
Please, Sign In to add comment