Curl image "error=2, no such file or directory"

Hi folks,

sry for this question, but i’m a linux noob :wink:

First of all, i’m using OH3.1.0.M4 on Openhabian.

I try to grab a image from my synology surveillance station and save it within a rule to a file to final forward the image via mail.

The variable fdCamURL contains the url of the image as a string (without authentication).
The variable fdCamSnapTmp contains “/etc/openhab/snap/test.jpg”

I created a directory “snap”:

image

This is the command within the rule:

executeCommandLine("curl -m 10 -o " + fdCamSnapTmp + " " + fdCamURL)

This is the output from the logfile:

When i copy the URL from the logfile and open it into a browser, the image of my webcam appears.

If you have any advise for a me, you are welcome :wink:

Thx,

Sascha

The syntax of executeCommandLine in OH3 requires a comma between each argument of the command. Try if
executeCommandLine("curl", "-m", "10", "-o", fdCamSnapTmp, fdCamURL )
works. You may need to add the wait parameter to wait until the image is downloaded and stored.

Hi Wolfgang,

first of all: thx for your reply.

After the change, no error appears, but also no file is stored within the directory. Do you now how a can add the timeout to check this out?

King regards

Sascha

I suppose you could try the documentation?

Hi @ll,

i’ve tryied out a lot of things:

1. I tried so separate the arguments via ,

executeCommandLine("curl", "-m", "10", "-o", fdCamSnapTmp, fdCamURL )

No more error message appears but no file will be stored within the directory.

2. I tried to use less arguments, add the path of curl and added a timeout:

executeCommandLine(Duration.ofSeconds(5),"/usr/bin/curl",fdCamURL,"-o",fdCamSnapTmp)

The result is still the same: No error, no file!

3. I open a ssh connection to openhabian and enter the command manualy:

image

It works fine! The file is stored within the directory.

This is my used code:

val fdCamURL = "\"" + SS_CAM1_Url.state.toFullString + "\""
val file = "test.jpg"
val fdCamSnapTmp = "/etc/openhab/snap/" + file
executeCommandLine(Duration.ofSeconds(5),"/usr/bin/curl",fdCamURL,"-o",fdCamSnapTmp)
logInfo ("Surveillance", fdCamURL + "-o" + fdCamSnapTmp)

Only the loginfo will be shown within the log viewer:

I become desperate. It has to be a stupid user error :wink:

Sascha

You would like to store the image in

right ?
What is the permission of this directory ?
You may assign the return value of executeCommandLine to a variable and also add that to the logging with logInfo. I would suppress the progress bar output ( curl has a silent/quiet switch ).

Hi Wolfgang:

This is the permission of the folder:

image

I changed and give the openhab user the ownerchip:

image

Nothing changed:

Next try:

var ScriptResponse = executeCommandLine(Duration.ofSeconds(5),"/usr/bin/curl",fdCamURL,"-o",fdCamSnapTmp)
logInfo ("Surveillance", ScriptResponse)

Ups…what is that? Everything after http ist missing?!? I have to escape the : ?

This is the value of my variable:

It works…

val fdCamURL = SS_CAM1_Url.state.toFullString
val file = "test.jpg"
val fdCamSnapTmp = "/etc/openhab/snap/" + file
var ScriptResponse = executeCommandLine(Duration.ofSeconds(5),"/usr/bin/curl",fdCamURL,"-o",fdCamSnapTmp)
logInfo ("Surveillance", ScriptResponse)
logInfo ("Surveillance2", fdCamURL)

I have to remove the

"\""

arround the SS_CAM1_Url.state.toFullString

I had insert this in cause of the curl command…ok, thank you very mutch for your advise.

Sascha

1 Like