Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. '''
  2. Crashplan query script
  3.  
  4. Queries the crashplan server using subprocess calls and formats the output
  5.  
  6. '''
  7.  
  8. import subprocess
  9. import json
  10.  
  11. password = raw_input("What password do you want to use: ")
  12.  
  13. sitelist = ['US - DC - Washington', 'US - FL - Miami', 'US - GA - Atlanta', 'CA - Toronto']
  14. cmdsites = ""
  15.  
  16.  
  17. for each in sitelist:
  18. cmdsites = cmdsites + '(OfficeLocation={})'.format(each)
  19.  
  20. ldap_cmd = "ldapsearch -xLLL -S OfficeLocation -h ldap.local.x.com -b cn=users,dc=x,dc=com '(&(!(gidNumber=1088))(|%s))' | grep -w 'uid:' | awk {'print $2'}" % cmdsites
  21.  
  22. users = subprocess.check_output([ldap_cmd], shell=True)
  23.  
  24. ##### EVERYTHING WORKS UP TO THIS POINT #####
  25.  
  26. for each in users:
  27. # subprocess.call(['curl -X GET -k -u "admin:'+password+'" "https://crashplan.x.com:4285/api/User?username='+each+'@x.com&incBackupUsage=true&strKey=lastBackup"'], shell=True) ### THIS COMMAND WORKS IT JUST GETS PASSED THE WRONG USERNAME
  28. print each #### THIS PRINTS OUT ONE LETTER PER LINE ####
  29.  
  30. print type(users) #### THIS PRINTS OUT ONE NAME PER LINE ####
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement