Can someone clarify my usage of executeCommandLine?
I am running openHab2 on a Windows 7 machine.
I am trying to use executeCommandLine in a very simple rule example.
The code below shows what I’m trying to do and the error messages I’m getting in the log file
(openhabinput.txt is a text file with a single line “the lights need adjustment” which I’ve tried placing in various folders)
//Turn on the wemo mini switch when openhab2 launches rule "1st rule" when System started then // val input = "the lights need adjustment"//this works fine // val input = executeCommandLine ("echo the lights need adjustment")//doesn't work //[ERROR] [lipse.smarthome.io.net.exec.ExecUtil] - couldn't execute commandLine 'echo the lights need adjustment' //java.io.IOException: Cannot run program "echo": CreateProcess error=2, The system cannot find the file specified // val input = executeCommandLine("head -n 1 C:\\openhabinput.txt", 1000)//doesn't work val input = executeCommandLine("head -n 1 openhabinput.txt", 1000)//doesn't work, same error message //[WARN ] [lipse.smarthome.io.net.exec.ExecUtil] - Execution failed (Exit value: -559038737. //Caused by java.io.IOException: Cannot run program "head" (in directory "."): CreateProcess error=2, The //system cannot find the file specified) if (input.contains("lights")) Switch1_state.sendCommand(ON) end
some of my many questions include:
- documentation of the Exec bindings does not seem to match the usage in this example:
- all the other threads I could find on this forum seem to be using executeCommandLine on a UNIX system. What would be an example string for the executeCommandLine argument on Windows?
- in another thread, instead of “val input =” the programmer used “var string input =”. With a lowercase word “string”. I thought all object types in openHab2 are case sensitive. No?
Thanks in advance