Mar-15-2019, 08:04 AM
Hi All,
below script to download DSLAM configuration, getting "error a bytes-like object is required, not 'str' "
tried with encoding, still getting error
HTTP request sent, awaiting response... 200 OK
below script to download DSLAM configuration, getting "error a bytes-like object is required, not 'str' "
tried with encoding, still getting error
import os import csv import subprocess import time dslamUser = "admin" dslamPass = "1234" httpresponse = '200 OK' with open('dslams.csv', 'r') as csvfile: x = csv.reader(csvfile, delimiter=',', quotechar='|') for row in x: dslam = list(row) dslamName = dslam[0].strip() dslamAddr = dslam[1].strip() print('Now Trying:{} IP:{}'.format(dslamName,dslamAddr)) print ('Authenticating with DSLAM....') cmdargs = "--auth-no-challenge -t 5 --http-user=" + dslamUser + " --http-password=" + dslamPass + " http://" + dslamAddr + "/config-0_.dat -O /dev/null" data = "" while not ('200 OK') in data: task = subprocess.Popen("wget " + cmdargs, shell=True, stdout=None, stderr=subprocess.PIPE) time.sleep(3) dummy, data = task.communicate() os.system("wget --auth-no-challenge -t 5 --http-user=" + dslamUser + " --http-password=" + dslamPass + " -O '" + dslamName + "_'`date +%Y%m%d%H%M`'.dat' http://" + dslamAddr + "/config-0_.dat")
Error:Now Trying:24K_Glamore-1 IP:10.217.128.93
Authenticating with DSLAM....
Traceback (most recent call last):
File "zyxelbackup.py", line 22, in <module>
while not ('200 OK') in data:
TypeError: a bytes-like object is required, not 'str'
Want to capture HTTP responseHTTP request sent, awaiting response... 200 OK