Executing command on command line

is it fine if i use this in item

Switch power
Switch channelup





and now in rule

import ???
rule "anything it doesnot matter"
when
Item power received command ON
then
executeCommandLine(“irsend SEND_ONCE ~/akaitv.conf KEY_POWER”)
end

Yeah that should do it.

it does not work.it says it says it is executing command but in actual anything does not happen.as i had not imported anything.please tell what to do as i even tried to execute this(( "sudo cp ~/akaitv.conf ~/checking.conf ))) but it does not do anything.so i think there is need of a binding.to be imported

As stated above I had issues getting this to work.

As also stated above, try saving the command you want to execute into a shell script, and calling that instead.

See the second half of my first post.

is there need to import any binding ???

the path of file is to to given from where ie home,root,pi or somewhere else

No, no binding needed. You need to create the TV.sh and make it executable as explained.

but address is to be given from where as openhab is in /opt/openhab

It depends on your file structure and where you save your TV.sh file. If saved in scripts and you’re running OH2, then /opt/openhab/conf/scripts/TV.sh should work.

i simply paste this command on my command line after saving tv.sh in scripts.but it sys cant find the directory

again it depends on your file structure.

navigate to the folder where you saved the TV.sh file and enter this on the command line:

echo $(cd $(dirname “$1”) && pwd -P)/$(basename “$1”)

it will give you the path of that directory. Use that in front of the TV.sh.

when i try to run script from command line it works.as it can be seen.

when same thing goes from here i check again but it does not work.

so there is problem with working of openhab as it seems to working fine from command line.i have changed the script for making a file workingcheck but it does not form anything

is there need to download anythiing as i am had installed only openhab,neither of his addons and neither any demo. and even in one tutorial it wasmention you need java-jdk.i had not even downloaded that

The setup you have now works for me. I am using openhab 2, and did install oracle jdk. This may be your issue.

I’m getting crazy
 I have openhab 2 installed with distro. Everything works well but I can’t run any script.
I think it is a problem of permission. Openhab is installed on raspberry pi and automatically started at boot as service.
If I execute the script from account pi it works, if I do that using the openhab UI the command is received but nothing happens

The owner and the group of the script file is openhab.
I don’t know what to do anymore
 If someone can help me I will be very grateful :slight_smile:
Thank you all

I think you have to have the openhab exec binding installed for executeCommandLine to work. If you installed openhab with apt-get, then you should install the binding with apt-get too:
sudo apt-get install openhab-addon-binding-exec
If you didn’t use apt-get to install openhab, you can probably just copy this addon to your addons directory:
org.openhab.persistence.exec-1.8.3.jar
or whatever version of openhab you’re using.

You can see this post for other suggestions on making executeCommandLine work:
https://community.openhab.org/t/solved-exec-binding-does-nothing-on-executecommandline/8778/10

@lorenzo81 mentioned that he is using openHAB 2. Bindings are not installed using apt with OH2 anymore. In order to install the Exec binding, simply go into PaperUI and install it from there.
Problems with exec are quite common as a lot has to be remembered. Please follow the link posted by @Ken_Van_Camp and be sure to look at the openhab.log. If you do not make progress, post your Exec line here.

Thank you, finally I found a solution to my problem. Actually it was due to sudoers configuration file. :slight_smile: See this post:

Hi friend what if my command includes quotation marks, for example:

epseak "Hello World"

then what is the syntax when using executeCommandLine in rules file
Please help me
Thanks