Problem using executeCommandLine and curl


I’m trying to execute a simple url call to push a notification to pushbullet, using curl and executeCommandLine

The following works from the command line:

curl --header 'Access-Token: [my API]' -X POST --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "Test Title", "body": "Test Body"}'

So I expected this would work from an openhab rule:

executeCommandLine("curl --header 'Access-Token: [my-API]' -X POST --header 'Content-Type: application/json' --data-binary '{\"type\": \"note\", \"title\": \"Test Title\", \"body\": \"Test Body\"}'")

but it doesn’t - does anyone have any insight into what might be the problem?



Hi Dan,

It seems that the command line needs to be formatted in a special way. Check out this example.


1 Like

Thanks - not sure I follow from that what formatting changes are needed. Do you know if there’s a summary somewhere?

I test and with this it works:

executeCommandLine("curl@@-k@@-H@@Access-Token: [apiToken]@@-XPOST@@ application/json@@--data-binary@@{\"type\": \"note\", \"title\": \"Test Title\", \"body\": \"Test Body\"}@@")

Wow - thank you. Bloody complicated!

Wasn’t sure if I should start a new thread or hijack this one?
I am trying to call a script with executeCommandLine but it doesn’t seem to work.

This works in command line but not in rules:

/usr/bin/python3 /volume1/homes/mark/scripts/pythonremote/ --message SGS6 message

I have tried below without luck:


Any suggestions?

I used to execute Python scripts successfully with this syntax

executeCommandLine("python@@./configurations/scripts/ relevant and witty@@")

That was getting a bit messy and my attempts at doing it via the exec binding were not going well.

Someone on another thread mentioned this method described here:

I adapted it and after the usual 4 hours of hair pulling, it worked!

I have no idea why you have to put …

 + " "

…after the variable.

I guess it is just one of the many “precious” little tests that OpenHAB likes to put us through, to abandon everything we have learned from nearly every other language :smile:

rule "Ivona TTS"
    Item Speak_Ivona changed
    var String command
    var String commandFull

    logDebug("Ivona_TTS", "String " + Speak_Ivona.state + " ")
    command = "python3@@/opt/openhab/configurations/scripts/"
    commandFull = executeCommandLine(command + Speak_Ivona.state + " ")


So I can now just update the item with what I want it to say

    postUpdate(Speak_Ivona, "Hinkle Finkle DInkle Doo")

Hope it helps and bonus points if you know who said those words :wink:


I tried use this syntax in a rule executeCommandLine("python@@./home/pi/ ") or
executeCommandLine(“python@@/home/pi/ “) or
executeCommandLine(”/usr/bin/python /home/pi/”) etc…

the log response is always positive (for exemple: "executed commandLine ‘python’ ")
but the script doesn’t work as it does when I launch it normally from the terminal
I’m running on a rasp jessie
what should I write? thanks

I am not sure, I appear to be struggling a little with it this week. What once worked, now doesn’t.

I think my issues are permission related due to removing my manual install and reinstalling via apt-get (I’m on Wheezy on a Pi). I.e. having to make sure script and rule files were now owned by user “openhab” rather than “pi”. I also had to add openhab to the group “audio”.

Not sure my experience is relevant but it might point you in the right direction :slight_smile:

If you haven’t already may be worth temporarily running openhab as root, just to see if that fixes things. If it does then definitely a permissions issue.

It wasn’t a permission issue, I had to specify the path of a file in the script. thank you anyway!