Page 1 of 1

Pulling the bandwidth.csv file with python

Posted: Thu Jan 19, 2017 3:30 pm
by psycik
So I'm trying to download the bandwidth.csv file. I know I have to post to get_password_cookie.sh keep the cookies and then ask for the file.

But having trouble doing it.
Any help?
# Read CSV File
url='http://mygargoylerouter/utility/get_password_cookie.sh'
s =requests.session()
p = dict(postparms = 'mygargoylepassword')
headers = {'content-type': 'application/x-www-form-urlencoded'}
r = s.post(url,params = p,headers=headers)
print r
print r.text
c = r.cookies
r = requests.get('http://mygargoylerouter/bandwidth.csv', cookies = c, verify = False)

Seems to pull back a page, but I don;t think I'm logged in.

Re: Pulling the bandwidth.csv file with python

Posted: Sat Feb 04, 2017 10:10 pm
by AllanMarcus
I think you can just ssh to the server and run:

Code: Select all

	cat /tmp/bw_backup/do_bw_backup.sh | grep bw_get | sed 's/.*bw_get/bw_get/' | sed 's/\-f .*/-t/g' > /tmp/tmp.bw.sh
	sh  /tmp/tmp.bw.sh | sed 's/^[^\-]*\-//g' |  sed 's/\-/,/g'
	rm  /tmp/tmp.bw.sh
this is from /www/bandwidth.csv

Re: Pulling the bandwidth.csv file with python

Posted: Sun Nov 19, 2017 5:12 am
by ABza
Hi Allan,
Thanks for the tip. Does this create a CSV file somehere? Do you perhaps have an idea on how to get the file onto my Windows PC every day on a schedule?
Regards
ABza

Re: Pulling the bandwidth.csv file with python

Posted: Sun Nov 19, 2017 1:17 pm
by psycik
You have to use the code I posted two posts up. For windows I had to write a csharp program so I could store the authentication cookie