Controlling openhab from commandline

Hi,

I just want to execute a script from OSGI command console (which you get with ./start.sh), but im getting errors:

osgi> openhab
—openHAB commands—
openhab send - sends a command for an item
openhab update - sends a status update for an item
openhab status - shows the current status of an item
openhab items [] - lists names and types of all items matching the pattern
openhab say - Says a message through TTS on the host machine
openhab > - Executes a script

osgi> openhab > demo
___ demo
Couldn’t resolve reference to JvmIdentifiableElement ‘demo’.; line 1, column 0, length 4

I also tried setting up xmmp, but that seems overkill for just wanting to execute a script.
Xmmmp connects, but it doesnt receive the messages from the other user. The tutorial says it should work: https://github.com/openhab/openhab/wiki/Scripts (Section: Calling Scripts) But it seems the openhab xmpp user doesnt receive hte messages. But i can see its online status.

What todo?

This user has a similar question: OSGI Console: Openhab script call

Do you mean that there is no command to call a script? If so, you might set up a String item like

String CallScript

and a rule

rule Call
when
  Item CallScript received command
then
  callScript(receivedCommand.toString)
end

and then at the console

osgi> openhab send CallScript myScript

(untested!)

(Note formatting went wrong in the initial question)

I mean that the openhab > <script> command in the osgi console, which is the input/ouput via the console after you run ./start.sh, doesnt work.

You could try reproducing it yourselve:
./start.sh
help openhab
openhab > scriptname

Note, its openhab 1.8, not 2.0

Example output:

help openhab
---openHAB commands---
	openhab send <item> <command> - sends a command for an item
openhab update <item> <state> - sends a status update for an item
openhab status <item> - shows the current status of an item
openhab items [<pattern>] - lists names and types of all items matching the pattern
openhab say <sentence to say> - Says a message through TTS on the host machine
openhab > <script to execute> - Executes a script

osgi> openhab > demo
 ___ demo
   Couldn't resolve reference to JvmIdentifiableElement 'demo'.; line 1, column 0, length 4
osgi>

I understand now, sorry. This works for me:

openhab > "12 * 5"

prints out

60

Ah clear, you have to pass in a string. The help should say:

openhab > "<script to execute>" - Executes a script

The quotes are important