Curl --anyauth -u user:pass http://ip/ as OH2 rule

from raspbian command line this is working:
curl --anyauth -u root:pw ‘

Without --anyauth curl answers “UNAUTHORIZED” and ended not correctly

Openhab2 rule:

Item JA65_Home changed from OPEN to CLOSED

does not work.

How can be --anyauth implemented ?

Call curl using executeCommandLine.

Many thanks Rich.
But still not working. Must be a rule of \ or ’ or " in the statement.

executeCommandLine("curl --anyauth -u root:pw ''")

NOK - with \ before ’
executeCommandLine("curl --anyauth -u root:pw \'\'")

NOK -with \ before ’ and "
executeCommandLine(\"curl --anyauth -u root:pw \'\'\")

In karaf
log:tail exec
i can see:
10:44:22.180 [INFO ] [] - executed commandLine 'curl --anyauth -u root:pw '''

with double ’ on end

but the variable is still not deactivated.

From curl direct all OK.
curl --anyauth -u root:pw ''

I can’t solve this for a couple of days. Thanks for any help.

I don’t have an answer for your issue using the command line but I would remove your password from your post.

1 Like

Try to replace spaces with @@ characters, e.g.

executeCommandLine("/usr/local/bin/speedtest-cli@@--simple", 120*1000)

All the spaces, like this:

I’m not sure if ' character should be escaped too.


1 Like

Thank you very much Kuba.
This solves my problem no ’ single quotas :0) and space to @@
curl statement should be as a string without spaces and ’


Add a timeout to the call to executeCommandLine and save and log the result of the call so you can see exactly what curl is complaining about.

val result = executeCommandLine("curl ...", 5000)
logInfo("test", result)

That could more easily pinpoint your problem rather than trial and error.

Sometimes you have to double escape the escapes: i.e. \\' to get it to pass through the multiple parsers between your rule and the command line.

Does curl actually require the URL to be in quotes? You might be able to bypass this issue entirely if not.

Hi Rich,
thaks for help. Solution from Kuba works. Curl doesn’t require the URL quotes.
I found this article on github to:
Maybe usefull for other user.

1 Like

good evening,

I have the problem that the command cannot be executed from the command line.

the link works with the browser.

does something have to be released in the Axis camera?

Greetings Michael

What’s your command?