JSscripting and executeCommandline

Could anybody please have a look?
I try to execute a command but no matter what I try I do not get it wrking.

var Duration = Java.type("java.time.Duration");
var content = actions.Exec.executeCommandLine(Duration.ofSeconds(5), "egrep", "'WARN|ERROR' /var/log/openhab/openhab.log");
console.log("Log: ",content);

Log:

[WARN ] [rg.openhab.core.io.net.exec.ExecUtil] - Timeout occurred when executing commandLine '[egrep, 'WARN|ERROR|FATAL' /var/log/openhab/openhab.log]'
[INFO ] [org.openhab.automation.script       ] - Log:  null

same when using time.duration… directly?

actions.Exec.executeCommandLine(time.Duration.ofSeconds(5),”…”)

Do you need more than one input field like this?
actions.Exec.executeCommandLine("/etc/openhab/scripts/ptz.sh", "Cam5", "GotoPreset", "99")

the script itself is working fine. no problem with

var content = actions.Exec.executeCommandLine(Duration.ofSeconds(5), "ls", "-la");

I thought the problem is related to quotes '. I tried to escape them and even removed them by just using WARN. Still does not work…

It’s a timeout, not a syntax error.
Whatever you’ve asked it do, it takes longer than 5 seconds. Seems to be processing logfiles?

the command inside a shell is executed instantly # less than a tenth of a second. Even if I increase the timeout to 15 I still get a timeout error.

So it is not returning from your instruction …
I don’t know why that would be, maybe it gets piped off to somewhere else.

True, probably because of the syntax.
Which brings us back to post #1.
This is what I tried - and I do not see a chance to come to an end without an expert:

//1. different handling of parameters
(Duration.ofSeconds(5), "egrep", "'WARN|ERROR' /var/log/openhab/openhab.log");
(Duration.ofSeconds(5), "egrep", "'WARN|ERROR'", "/var/log/openhab/openhab.log");
(Duration.ofSeconds(5), "egrep 'WARN|ERROR' /var/log/openhab/openhab.log");
//2. escaping
(Duration.ofSeconds(5), "egrep", "\'WARN|ERROR\' /var/log/openhab/openhab.log");
(Duration.ofSeconds(5), "egrep", "\'WARN|ERROR\' \/var\/log\/openhab\/openhab.log");
(Duration.ofSeconds(5), "egrep", "\'WARN\|ERROR\' \/var\/log\/openhab\/openhab.log");
(Duration.ofSeconds(5), "egrep", "\'WARN||ERROR\' \/var\/log\/openhab\/openhab.log");

… plus many combinations of those 2 categories

When you run from executeCommandLine(), it is not a console, not in a shell. The usual workaround is to put your instruction in a file and run that.

You don’t seem to have tried breaking up your command line though - visible spaces inside your arguments are usually a bad sign
executeCommandLine("x", "y", "z")

I did, But I inserted two lines right after publishing the above post which you probably haven’t noticed.
Yeah, looks like I need to take the “fool” approach. Which is a pitty. I wanted to create a widget and rule which shows recent warnings, errors and fatal messages, nicely presented in a tabbed popup and wanted to add it in the market place. creating a shell script could be an obstacle for new users.

And from personal perspective I hate to give up and miss a chance to learn a bit more

Have you tried this without the pipe character? That really looks like a source of trouble.

Wow. I need to stop writing JS rules. An hour ago when I had this Out of Memory error again, stoping OH and restarting Pi led to Pi not coming up again. So I had to switch off my Pi.
After that the script works without problems :man_facepalming:

This 3.2 release is driving me nuts