All i am looking to do is append the string i built to a file. I’ve tried escaping this every which way with numerous quotes, double quotes, @@s etc…I can’t figure it out.
Any help greatly appreciated.
Why would you like to use >> ? >> has special functionality in shells. executeCommandLine does not offer full shell functionality.
Try it without these characters. I assume you would like to append some stuff to the end of the file.
Create a batch file that uses FrontDoorLogString.state as an argument and then do the redirection to the end of the file in the batch file.
Simple arguments that contain no spaces can be separated with spaces, for example executeCommandLine("touch file.txt"). When one or more arguments contain spaces, use @@ instead of a space as the argument separator. For example the bash command touch -t 01010000 "some file with space.txt" will have to be written as touch@@-t@@01010000@@some file with space.txt.
Your statement has two spaces. Replace them with @@.
"sudo@@/log/var/openhab2/FrontDoor.sh@@"
There may be other issues, but that’s what jumps out to me.
2023-02-22 07:07:27.275 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘Test.rules’ has errors, therefore ignoring it: [25,61]: no viable alternative at input ''
User does have access; i can run it from a command line; just can’t get it constructed in openhab 2.11 to get it to either load or run; depending on how I try to escape out of all the quotes.
problem is that im trying to send it an item state…to do that i need to escape out but still surround in in quotes…which i can’t figure out the correct syntax
the problem is; i’m trying to pass an item state to it; and i can’t figure out how to escape the double quotes and or insert them into the command properly
I know what you mean. I had the same problem some time ago. But why don’t you use a workaround.
A door state has two states or three when you can lock it up.
You could use it this way:
if(door.state == open){
executecommandline(“open”)}
True; good point…But i also want to capture the rest with the date and time etc…so the problem would still persist. If i took the item station out; I’d still need to construct the date/time string
I mean maybe write two scripts then; my guess is a shell script could write out a date thats possible and then use your suggestion to run one or the other script.
Oh wow, this is very close!!! Thanks…only thing is it overwrites the data each time; and doesn’t append it. How can I get this to just append new lines each time.
I think i got it; I put an extra > in the first line of the script; that works then.
Can you explain to me what this does: logInfo(“FrontDoor”, result )
I stand corrected; looking a bit further:
I opened the door and closed it within 5 secs.
This is what logged: the open comes before the close.
The timestamps in the string builder are way off 8 minutes in between; no way. it was 5 secs max.
CLOSED - 2/24 | 12:56
Fri Feb 24 13:04:32 EST 2023
OPEN - 2/24 | 13:4
Fri Feb 24 13:04:34 EST 2023
right. did it as I was not sure what you exactly would like to get.
That should log the return value - especially in case of problems to the openhab.log file.
The row with the datetime stamp created by the date command should nearly be the time you opened/closed the door. Your open time seems to be ok.
According to the linux datetimestamp it was two seconds between open and close.