#!/usr/bin/env python import commands, os, urllib # Connection info user = "user" passw = "pass" ip = "1.2.3.4" theurl = "http://%s:%s@%s:2086/scripts/fetchcsv" %(user, passw, ip) f = urllib.urlopen(theurl) #Establish initial login session cmd = "curl --location-trusted --cookie-jar cpcookies.txt -o /dev/null 'http://%s:2082/login?user=%s&pass=%s&login_theme=cpanel'" %(ip, user, passw) os.system(cmd) # Get reseller's backup cmd = "curl --location-trusted -b cpcookies.txt -c cpcookies.txt -o %s.tar.gz http://%s:2082/getsysbackup/daily.tar.gz" %(user, ip) os.system(cmd) for x in f.readlines(): info = x.split(",") user = info[3] #Switch session user cmd = "curl --location-trusted -b cpcookies.txt -c cpcookies.txt -o /dev/null http://%s:2082/xfercpanel/%s" %(ip, user) print cmd os.system(cmd) #Get backup file cmd = "curl --location-trusted -b cpcookies.txt -c cpcookies.txt -o %s.tar.gz http://%s:2082/getsysbackup/daily.tar.gz" %(user, ip) print cmd os.system(cmd) #print commands.getoutput(cmd) #os.system("mv cpcookies2.txt cpcookies.txt") print "Done getting backups." print