``Hi Alain,
Thanks very much for the help. Unfortunately, I still can’t get it to work!!
I copied your rule and pasted into my rules file. I created a directory at C:\OH_utils and put head.exe and esai.txt into this directory.
I must have checked my directories and entries at least 10 times. When I run the program, the log file doesn’t report any error but here is the logging output:
2018-01-17 14:09:20.324 [INFO ] [eclipse.smarthome.model.script.DEBUG] - From essai.txt :
I did create a rule with
executeCommandLine("notepad.exe")
and it pops up a notepad exactly as expected
I am going to leave this alone for a while since I do have my workaround. When openhab works it’s really a wonderful program. But when I find myself banging my head against something that should be straightforward (which I often do) I have to go off and calm down.
//Working rule copied from the forum advice
rule "Un test"
when
System started
then
val input = executeCommandLine("C:\\OH_utils\\head@@-n@@1@@C:\\OH_utils\\essai.txt", 1000)
logInfo("DEBUG", "From essai.txt : " + input)
if (input.contains("first")) logInfo("DEBUG", "the line contains <first> !")
end
As I stated in my previous post, I copied and pasted the rule from above , created a directory C:\OH_utils\ and in that directory I put head.exe and essai.txt . essai.txt contains a single line:
This is the first line in my file
I will not be surprised if the problem in hindsight turns out to be something simple and obvious. But I sure can’t see it.
Regards,
Joe
After some research, I realized that there are several versions of head.exe for Windows hanging around on the web.
Some, as this one : http://unxutils.sourceforge.net/, are self-contained (no emulation layer) and have no dependencies.
Other, as this one http://gnuwin32.sourceforge.net/packages/coreutils.htm, are built on Cygwin or Mingw and require some DLL (such as iconv-x, intl-x, depending on versions). If you run the second category on the command line you get a Windows error box reclaiming these DLL (if they are not already in the same directory).
And when you run OpenHAB-executeCommandLine with the second category, it remains silent but you get no result !
The test of my first message was made with a utility of the first category which was sitting on my PC. I tried with one of the second category and had the same result as you !
I suspect you used one of the second category and as you copied head.exe “into the top level of your OS partition”, or in OH_utils, you lost the DLLs on the way.
2018-01-19 18:33:40.772 [INFO ] [eclipse.smarthome.model.script.DEBUG] - From essai.txt : This is the first line in my file
2018-01-19 18:33:40.774 [INFO ] [eclipse.smarthome.model.script.DEBUG] - the line contains <first> !
Does notepad actually pop up with a form? I see executeCommandLine started the notepad process, but it is not visible on the screen… I wonder if have OH configured to start with the wrong user?