#!/bin/bash clear curl -o /tmp/context -X GET -i -H "Content-type: application/json" -c /tmp/cookies.txt "http://192.168.1.1/homeAuthentication.html?username=admin&password=HYJcanGE" #curl -o /tmp/context -X POST -i -H "Content-type: application/json" -c /tmp/cookies.txt "http://192.168.1.1/authenticate?username=admin&password=HYJcanGE" ID=$(tail -n1 /tmp/context | sed 's/{"status":0,"data":{"contextID":"//1'| sed 's/"}}//1') curl -b /tmp/cookies.txt http://192.168.1.1/sysbus/Devices -o /tmp/getHosts.txt #curl -b /tmp/cookies.txt -X POST -H 'Content-Type: application/json' -H 'X-Context: '$ID'' -d '{"parameters":{}}' http://192.168.1.1/sysbus/Devices -o /tmp/getHosts.txt #curl -b /tmp/cookies.txt -X POST -H 'Content-Type: application/json' -H 'X-Context: '$ID'' -d '{"parameters":{}}' http://192.168.1.1/sysbus/Hosts:getDevices -o /tmp/getHosts.txt curl -i -b /tmp/cookies.txt -X POST http://192.168.1.1/logout rm /tmp/cookies.txt rm /tmp/context