How to call strg.cfg with Auth (username and password)?

Albert25
Beiträge: 3
Registriert: Freitag 7. Februar 2014, 21:12

How to call strg.cfg with Auth (username and password)?

Beitrag von Albert25 » Sonntag 16. Januar 2022, 15:46

We have several "NET-PwrCtrl HUT" switches, version "HUT 5.0".

I want to query their status from a script, but cannot get the authentication to work. (the switch uses the default "admin" user and "anel" password)

When I do

Code: Alles auswählen

curl "http://power-1.example.lan/strg.cfg?Auth:adminanel"
I get

Code: Alles auswählen

401 Unauthorized: Password required
The same command does work on another switch which doesn't require authentication.

How should the authentication be sent for HTTP queries?

Thanks

Albert25
Beiträge: 3
Registriert: Freitag 7. Februar 2014, 21:12

Re: How to call strg.cfg with Auth (username and password)?

Beitrag von Albert25 » Donnerstag 12. November 2026, 16:10

Well, almost 5 years later, I come across this post. In the meantime, I had found the solution, but forgot to post it here in case others find it useful.

This works:

Code: Alles auswählen

curl -s --user "admin:anel" "http://power-l.example.lan/strg.cfg"
We use it in this script:

Code: Alles auswählen

#!/usr/bin/env bash

# Show state of Anel power switches

user=admin
pass=anel

for host in power-l power-p; do
	echo "* $host"
	curl -s --user "$user:$pass" "http://$host.example.lan/strg.cfg" \
	| perl -a -F";" -nle '
	    print "  ($F[7] °C)";
	    foreach $i (0..7) {
	      print "  ", $i+1, " : ", ($F[$i+20]? "ON" : "  "), "  $F[$i+10]"
	    }
	  '
	echo
done

Antworten