Python Forum
HTTP response capturing issue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTTP response capturing issue
#2
Code is much easier to read if you use f-string (python 3.6 or newer required)
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(f'Now Trying:{dslamName} IP:{dslamAddr}')
        print ('Authenticating with DSLAM....')
        cmdargs = f"--auth-no-challenge -t 5 --http-user={dslamUser} --http-password={dslamPass} "
            f"http://{dslamAddr}/config-0_.dat -O /dev/null"
        data = ""
        while not ('200 OK') in data:
            task = subprocess.Popen(f"wget {cmdargs}", shell=True, stdout=None, stderr=subprocess.PIPE)
            time.sleep(3)
            dummy, data = task.communicate()
        os.system(f"wget --auth-no-challenge -t 5 --http-user={dslamUser} --http-password={dslamPass} "
            f"-O '{dslamName}_'`date +%Y%m%d%H%M`'.dat' http://{dslamAddr}/config-0_.dat")
Reply


Messages In This Thread
HTTP response capturing issue - by anna - Mar-15-2019, 08:04 AM
RE: HTTP response capturing issue - by Larz60+ - Mar-15-2019, 01:59 PM
RE: HTTP response capturing issue - by Larz60+ - Mar-15-2019, 03:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Capturing BS4 values into DF and writing to CSV cubangt 18 2,018 Sep-05-2023, 01:57 PM
Last Post: cubangt
  capturing multiline output for number of parameters jss 3 849 Sep-01-2023, 05:42 PM
Last Post: jss
  Json filter is not capturing desired key/element mrapple2020 1 1,172 Nov-24-2022, 09:22 AM
Last Post: ibreeden
  ModuleNotFoundError: No module named 'http.client'; 'http' is not a package abhishek81py 1 15,573 Jun-25-2020, 08:58 AM
Last Post: buran
  Capturing inputs values from internal python script limors11 11 5,253 Jun-16-2019, 05:05 PM
Last Post: DeaD_EyE
  Capturing a snapshot from the video sreeramp96 1 2,195 May-24-2019, 07:02 AM
Last Post: heiner55
  httplib to http.client conversion issue zatlas1 1 2,616 Apr-12-2019, 05:21 PM
Last Post: Larz60+
  HTTP response capturing issue miunika 1 2,070 Mar-16-2019, 01:46 PM
Last Post: Larz60+
  HTTP 400 response code eshwinsukhdeve 1 1,759 Mar-03-2019, 06:11 PM
Last Post: Larz60+
  Capturing error from sql Grego 1 2,476 Jun-29-2018, 11:17 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020