Commit a5a03749 authored by Dietmar Maurer's avatar Dietmar Maurer

spice-example-sh: avoid use of sed and awk

parent 1933730b
......@@ -12,9 +12,13 @@ PROXY=anodename.domain.tld
DATA=`curl -k -d "username=$USERNAME&password=$PASSWORD" https://$PROXY:8006/api2/json/access/ticket`
TICKET=`echo $DATA|sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"// g'|grep -w ticket| awk -F "|" '{print $2}'`
TICKET=${DATA//\"/}
TICKET=${TICKET##*ticket:}
TICKET=${TICKET%%,*}
CSRF=`echo $DATA|sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"// g'|grep -w CSRFPreventionToken| awk -F "|" '{print $2}'`
CSRF=${DATA//\"/}
CSRF=${CSRF##*CSRFPreventionToken:}
CSRF=${CSRF%%,*}
curl -k -b "PVEAuthCookie=$TICKET" -H "CSRFPreventionToken: $CSRF" https://$PROXY:8006/api2/spiceconfig/nodes/$NODE/qemu/$VMID/spiceproxy -d "proxy=$PROXY" > spiceproxy
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment