Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ###################################
- # USAGE:
- # ./subs-export.csv.bash <ORG NAME>
- #
- # NOTE: If you run this without the
- # organization name as a parameter
- # it will return 0 results.
- ###################################
- echo "Name,Organization,Subscriptions"
- echo "SELECT '\"' || f.element || '\"','\"' || o.displayname || '\"','\"\"\"'||e.quantity||'|'||p.productid||'|'||p.productname||'|'||p.contractnumber||'|'||p.accountnumber||'\"\"\"' FROM
- cp_consumer c,
- cp_owner o,
- cp_pool p,
- cp_entitlement e,
- cp_consumer_facts f
- WHERE c.owner_id = o.id AND
- e.consumer_id = c.id AND
- p.id = e.pool_id AND
- f.cp_consumer_id = c.id AND
- f.mapkey = 'network.fqdn' AND
- 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