Curl command to copy image url to local file

I want to copy the image file which is a local URL coming from pushover (URL item) to a local file at /etc/openhab/camera/ipcamera.jpg. I have created the directory “camera” first.
Reason for this is that pushover needs to local file as attachment to show in the notification and the local URL as attachment will not work outside the network.

When I run the script:
executeCommandLine(Duration.ofSeconds(15), “curl --output /etc/openhab/camera/ipcamera.jpg”) I get the following error:
Failed to execute commandLine ‘[curl --output /etc/openhab/camera/ipcamera.jpg]’

All the rest is working :wink:
I have no clue whether the command is the issue or it might be permission.
Who can assist?

The exec binding has no shell so would not be able to find the curl command. Many people have had success creating a Linux shell script and running that with the exec binding.


This is what I have for the same situation:

    executeCommandLine(Duration.ofSeconds(30), "/usr/bin/curl", "-k", "", "-o", "/tmp/pic.jpg")
    logInfo("away", "Sending pushover message")
    val actions = getActions("pushover", "pushover:pushover-account:2424242424")
    actions.sendAttachmentMessage("No one at home and there's motion in the lounge", "", "/tmp/pic.jpg", "image/jpeg")

The things that looks different are a) I have separate arguments to executeCommandLine, b) I specify the full path to curl and c) I’m sticking the file in /tmp to avoid permission issues.

Not sure if any of those help at all.


1 Like

Worked straight away.
Thank you so much!!

Thanks Bruce. Andy helped me out.