无法发送XML发布请求HUAWEI-LTE E5336Bs-2设备

时间:2019-05-14 19:52:00

标签: xml bash curl huawei lte

运行此bash时,SessionID=文件中未分配的login_resp_hdr.txt

#!/bin/sh

MODEM_IP="192.168.8.1"
curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
LOGIN_REQ="<request><Username>asiacell</Username><Password>YWRtaW4=</Password><password_type>3</password_type></request>"

curl -X POST -d $LOGIN_REQ "http://$MODEM_IP/api/user/login" \
-c $COOKIE --header "__RequestVerificationToken: $TOKEN" \
--header "Content-Type: text/xml" --dump-header login_resp_hdr.txt > /dev/null

grep "SessionID=" login_resp_hdr.txt | cut -d ':' -f2 | cut -d ';' -f1 > session_id.txt
grep "__RequestVerificationTokenone" login_resp_hdr.txt | cut -d ':' -f2 > tokent.txt

SESSION_ID=`cat session_id.txt`
TOKENT=`cat tokent.txt`

echo "admin session_id\n$SESSION_ID\n"
echo "$TOKENT\n"

0 个答案:

没有答案
相关问题