[SOLVED] Executecommand cp not working

I created a director /etc/openhab/PicTemp
I have a script that dumps jpgs from an IP camera into it.
That works.
I also have a script to copy these to a network share.
That does not work.
No matter what I try, it runs, but doesn’t do anything.
The directory(PicTemp) has the same permission as the /etc/openhab/html directory drwxrwxr-x and the same users and group permissons openhab:openhab

I have another script that successfully moves the files from /etc/openhab/html and it works.
The script to move from PicTemp is identical; it will not work.
I’ve tried dozens of permissons combinations to no avail.

It is supossed to copy from the PicTemp directory to a mounted NAS.
script: sudo cp /etc/openhab2/PicTemp/Por1.jpg /mnt/MailBoxDumps/$(date +"%Y%m%d_%H%M%S").Por1.jpg

This script works if i dump the pics in the /openhab/html folder and am calling the script from the /openhab directory
It will not work if i dump the pics in /openhab/PicTemp

Open to any suggestions at this point.

The script run from openhab rule:
executeCommandLine(“bash /etc/openhab2/MovePorchSnaps.sh”)

If i run it in command line it seems to run but does nothing.


This probably means it’s failing silently. Check your assumptions and verify that this evaluates the way you expect:

$(date +"%Y%m%d_%H%M%S")

And what error code do you get?

I got it working in the command line; that was a user error with the MNT point it was copying to.
Fixed that, works from command line.

However, calling the script from openhab doesn’t seem to work.
Tried both of these over varying combinations of permissions on the PicTemp folder and the script itself.

executeCommandLine(“bash /etc/openhab2/MovePorchSnaps.sh”)
executeCommandLine(“sudo /etc/openhab2/MovePorchSnaps.sh”)

rwsrwsrwx openhab:openhab
rwxrwxrwx openhab:openhab
rwsrwsrwx root:root
rwxrwxrwx root:root
rwsrwsrwx root:openhab
rwxrwxrwx root:root:openhab

Here is the “fix”:

Need to use “bash” not “sudo” to call it
Oddly enough, if I have to use sudo to move it from html to the NAS

I had to remove sudo from the shell script.
Then, it works with the directory permissions the same as HTML and the script permissions = rwsrwsrwx with root:root as the owner