Help Sending a curl request (UPDATE KODI)

still the same response rule not worked file not exist

ran lisa again

[20:33:25] openhabian@openHABianPi:~$ ls -lisa /etc/openhab2/scripts/Kodi_rescan.sh
128000 4 -rwxrwxr-x 1 openhab openhabian 217 Aug  2 19:51 /etc/openhab2/scripts/Kodi_rescan.sh

[20:36:34] openhabian@openHABianPi:~$ ls -lisa /etc/openhab2/scripts
total 16
132872 4 drwxrwxr-x+  2 openhab openhabian 4096 Aug  2 20:18 .
132849 4 drwxrwxr-x+ 13 openhab openhabian 4096 Jul  2 23:10 ..
128000 4 -rwxrwxr-x   1 openhab openhabian  217 Aug  2 19:51 Kodi_rescan.sh
132873 4 -rw-rw-r--   1 openhab openhabian  236 May 28 09:33 readme.txt

strange… what’s your log like?

What part of the log would you like me too look at logs are big :wink:

Basically the part with “file not found”, a few lines above and below-

==> /var/log/openhab2/openhab.log <==

2018-08-02 20:50:44.520 [WARN ] [lipse.smarthome.io.net.exec.ExecUtil] - Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "/etc/openhab2/scripts/Kodi_rescan.sh" (in directory "."): error=2, No such file or directory)

2018-08-02 20:50:44.529 [INFO ] [thome.model.script.Kodi Library Scan] - 

==> /var/log/openhab2/events.log <==

2018-08-02 20:50:44.455 [ome.event.ItemCommandEvent] - Item 'Kodi_Rescan' received command ON

Thats all the log says

Could you try the simpler executeCommandLine in your rule? Are you running the snapshot?

This one:

executeCommandLine("/etc/openhab2/scripts/Kodi_rescan.sh")

i only did my rule like that as thats how its done in the turorial will change now …

rule "Kodi Video Library Scan"
when
	Item Kodi_Rescan received command
then
    executeCommandLine("/etc/openhab2/scripts/Kodi_rescan.sh")
end

log returns

2018-08-02 20:56:01.378 [ERROR] [lipse.smarthome.io.net.exec.ExecUtil] - couldn't execute commandLine '/etc/openhab2/scripts/Kodi_rescan.sh'

java.io.IOException: Cannot run program "/etc/openhab2/scripts/Kodi_rescan.sh": error=2, No such file or directory

	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) ~[?:?]

	at java.lang.Runtime.exec(Runtime.java:620) ~[?:?]

	at java.lang.Runtime.exec(Runtime.java:450) ~[?:?]

	at java.lang.Runtime.exec(Runtime.java:347) ~[?:?]

	at org.eclipse.smarthome.io.net.exec.ExecUtil.executeCommandLine(ExecUtil.java:63) ~[?:?]

	at org.eclipse.smarthome.model.script.actions.Exec.executeCommandLine(Exec.java:43) ~[?:?]

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1085) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1060) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._invokeFeature(XbaseInterpreter.java:1046) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeFeature(XbaseInterpreter.java:991) ~[?:?]

	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.invokeFeature(ScriptInterpreter.java:143) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:901) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:864) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:223) ~[?:?]

	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:219) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:446) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:227) ~[?:?]

	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:219) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:189) ~[?:?]

	at org.eclipse.smarthome.model.script.runtime.internal.engine.ScriptImpl.execute(ScriptImpl.java:82) ~[?:?]

	at org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleEngineImpl.lambda$2(RuleEngineImpl.java:345) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

Caused by: java.io.IOException: error=2, No such file or directory

	at java.lang.UNIXProcess.forkAndExec(Native Method) ~[?:?]

	at java.lang.UNIXProcess.<init>(UNIXProcess.java:247) ~[?:?]

	at java.lang.ProcessImpl.start(ProcessImpl.java:134) ~[?:?]

	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ~[?:?]

	... 33 more

==> /var/log/openhab2/events.log <==

2018-08-02 20:56:01.354 [ome.event.ItemCommandEvent] - Item 'Kodi_Rescan' received command ON

iv also got an extra kodi.sh file now

[20:58:51] openhabian@openHABianPi:~$ sudo find / -name Kodi_rescan.sh
[sudo] password for openhabian:
/etc/openhab2/scripts/Kodi_rescan.sh
/home/openhabian/Kodi_rescan.sh
/srv/openhab2-conf/scripts/Kodi_rescan.sh

Shouldn’t openhabian be a member of the openhab group? I don’t have an openHABian install right now so I don’t know how it gets set up by default, but in my mind it makes more sense to have the files be owned by openhab:openhab and have the openhabian user be a member of the openhab group.

That should work through samba, but perhaps it doesn’t. Like I said, I don’t have an openHABian install to work with right now so can’t check.

But the standard approach would be that the file’s would be owned by either the user’s group or by some other group that doesn’t correspond with a user (e.g. sudo, dialout, gpio, etc). To give a user access to the files one usually adds that user to the group owner of the file, not change the group ownership of the file itself to the other user’s group. But maybe this is caused by a limitation of the samba share.

The variant you used before catches the output and logs it. Therefore a timeout (5000ms) needs to be set.

But the curl commands don’t return anything. :wink:

Im getting a bigger error now posted above i also tried running the script in home folder same big error after changing the rule

It is, you are completely right.

chown with openhab:openhab
and
chmod with 775
should have been sufficient. But it also may be a samba thing, i have no idea.

All my files i created via VS Code use the scheme openhab:openhabian.

I can’t beleve i have been trying too get this too work chipping away for (25 Days) it was supposed to be a simple task :frowning:

Well, you are learning Linux. And on top of that excuting linux scripts with openHAB. That’s what taking time.

It took me about 10 minutes to set it up about a year ago. But this wasn’t my first script with openHAB and i have plenty of linux epxerience.

Which openHAB do you run? Snapshot perhaps?

Sorry i forgot you asked me for that info

No im running latest stable or i was when i installed it

###############################################################################
################# openHABianPi ################################################
###############################################################################
##             Ip = 192.168.0.94
##        Release = Raspbian GNU/Linux 9 (stretch)
##         Kernel = Linux 4.14.52-v7+
##       Platform = Raspberry Pi 3 Model B Plus Rev 1.3
##         Uptime = 0 day(s). 0:12:2
##      CPU Usage = 2.54 % avg over 4 cpu(s)  (4 core(s) x 1 socket(s))
##       CPU Load = 1m: 0.50, 5m: 0.79, 15m: 0.62
##         Memory = Free: 0.23GB (25%), Used: 0.71GB (75%), Total: 0.95GB
##           Swap = Free: 0.09GB (100%), Used: 0.00GB (0%), Total: 0.09GB
##           Root = Free: 11.44GB (82%), Used: 2.46GB (18%), Total: 14.53GB
##        Updates = 2 apt updates available.
##       Sessions = 1 sessions
##      Processes = 106 running processes of 32768 maximum processes
###############################################################################

              Welcome to            __  _____    ____  _
            ____  ____  ___  ____  / / / /   |  / __ )(_)___ _____
           / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  / / __ `/ __ \
          / /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ / / /_/ / / / /
          \____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/_/\__,_/_/ /_/
              /_/
                  openHAB 2.3.0-1 (Release Build)

Agreed i should lower my expectations of learning some of this stuff overnight im still happy tho :slight_smile:

This is why i love OH it exposes you too all this compex stuff i already love computers but OH is unreal

Same version here.

I think i am done. I can’t think of anything anymore. That’s similar to how execute scripts (i put the shell scripts in a subfolder recently).

Could you double check the characters in you rule? If you copy it to the linux shell and write an ls with a space in front, do you get the file listed?

ok im not sure what you mean there copy what part of my rule ?

New.rules

rule "Kodi Video Library Scan"
when
	Item Kodi_Rescan received command
then
    executeCommandLine("/etc/openhab2/scripts/Kodi_rescan.sh")
end

The command line you want to execute:

With and without the quotes, try both.

ls “/etc/openhab2/scripts/Kodi_rescan.sh”
and
ls /etc/openhab2/scripts/Kodi_rescan.sh

But please copy from your rule, don’t retype.

Nothing Happened i copied directly from my rule

[21:33:27] openhabian@openHABianPi:~$ ls "/etc/openhab2/scripts/Kodi_rescan.sh"
/etc/openhab2/scripts/Kodi_rescan.sh

[21:34:05] openhabian@openHABianPi:~$ ls /etc/openhab2/scripts/Kodi_rescan.sh
/etc/openhab2/scripts/Kodi_rescan.sh

I doubt nothing happened. I bet your Kodi is rescanning. put a line with

echo "kodi rescan"

somewhere in your shell script. (after the #!/bin/bash)

BTW, ls just shows the directory contents. I guess you executed it at first.

My kodi is definite not updating its online in front of me i did try again too make sure

#!/bin/bash
# Kodi Video Library Scan
echo "kodi rescan"

curl --data-binary '{ "json.....................