[SOLVED] External Shell Script wont Reload

Did you mean to have the ./ before logviewer.sh? Have you tried without?

Hi Danny,

i call my other scripts the same way with ./ they run.
And yes i tried also without, script wont reload after 60 sec.

1 Like

Go to the openhabian-config tool and select fix permissions, add needed packages, and mount svr then reboot and see if that helps.

You told it not to.

Set that to true if you want it to run every 60 seconds.

Thing exec:command:logviewer [command="/etc/openhab2/scripts/./logviewer.sh", interval=60, timeout=5, autorun=true] //Logviewer für die Sitemap

no effect :confused:
Dont reload… i must say no load at all.
I does nothing. Except i run the script direct from the shell.
Can i run the script with a rule ?
Like… when time cron…
then run script…
?

When you run on command line is this what you type?

yes i can run it like that:
/etc/openhab2/scripts/./logviewer.sh and events.html gets written
or i can run it like that:
/etc/openhab2/scripts/logviewer.sh and events.html gets also written

Does it run as the openhab user?

Link an Item to the out Channel and see what the script is returning when OH tries to run it.

-rwxr-xr-x 1 openhabian openhabian 569 Feb 4 20:37 logviewer.sh

thats the owner at the moment

one step closer:
that comes up in the log when OH try to write the events.html

2020-02-05 19:33:55.233 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'test.items'

==> /var/log/openhab2/events.log <==

2020-02-05 19:33:55.279 [.ItemChannelLinkAddedEvent] - Link 'BefehlOutput-exec:command:logviewer:output' has been added.

2020-02-05 19:33:55.287 [.ItemChannelLinkAddedEvent] - Link 'BefehlInput-exec:command:logviewer:input' has been added.

2020-02-05 19:33:55.294 [.ItemChannelLinkAddedEvent] - Link 'BefehlExit-exec:command:logviewer:exit' has been added.

2020-02-05 19:33:55.301 [.ItemChannelLinkAddedEvent] - Link 'BefehlRun-exec:command:logviewer:run' has been added.

2020-02-05 19:33:55.306 [.ItemChannelLinkAddedEvent] - Link 'BefehlLastexecution-exec:command:logviewer:lastexecution' has been added.

2020-02-05 19:33:59.660 [vent.ItemStateChangedEvent] - BefehlRun changed from NULL to ON

2020-02-05 19:33:59.702 [vent.ItemStateChangedEvent] - BefehlRun changed from ON to OFF

2020-02-05 19:33:59.716 [vent.ItemStateChangedEvent] - BefehlExit changed from NULL to 1

2020-02-05 19:33:59.733 [vent.ItemStateChangedEvent] - BefehlOutput changed from NULL to /etc/openhab2/scripts/logviewer.sh: Zeile 3: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 5: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 6: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 7: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 8: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 9: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 10: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 11: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 12: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 3: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 5: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 6: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 7: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 8: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 9: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 10: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 11: /etc/openhab2/html/events.html: Keine Berechtigung

/etc/openhab2/scripts/logviewer.sh: Zeile 12: /etc/openhab2/html/events.html: Keine Berechtigung

2020-02-05 19:33:59.738 [vent.ItemStateChangedEvent] - BefehlLastexecution changed from NULL to 2020-02-05T19:33:59.710+0100

I don’t speak German but I’m going to guess that the error means the openhab user doesn’t have permission two write to /etc/openhab2/html/events.html, which would be unusual but not impossible. As I asked previously, does it run as the openhab user? The errors indicate that it doesn’t, there is some sort of permission problem.

u guess right. theres a problem with the ownership.

the owner i guess at the moment is openhabian

-rwxr-xr-x 1 openhabian openhabian 569 Feb 4 20:37 logviewer.sh

It’s not the script’s ownership that’s a problem. Everyone has permission to run it. But the openhab user has to have permission to do everything that the script itself does. The error indicates that it doesn’t. I can’t call that command or it can’t write to the file or it can’t read the file or something.

ok as far as i can understand the “openhab” user does have the rights to execute the script
but not write the output of the script ?

I don’t know what the openhab user doesn’t have permission to do. But it doesn’t have permission to do something that the script does. You need to run the script as the openhab user and see what it’s doing that it doesn’t have the permission to do.

ok, now i am getting close to my knowledge boarder about linux :confused:
i guess the openhab user is “openhab” right ?
and then i have to change the ownership of the script to “openhab” ?

See if the runuser command might help …


runuser -l openhabian -c '/etc/openhab2/scripts/logviewer.sh'

If it reports an error… that should be something to investigate further…

[20:28:52] openhabian@openHABianPi:/etc/openhab2/html$ sudo runuser -l openhabian -c '/etc/openhab2/scripts/logviewer.sh'

2020-02-05 20:29:03,109: FireMotD: Info: No FireMotD ExportFile detected. Please generate with "sudo .\/FireMotD -S"

              Welcome to            __  _____    ____  _
            ____  ____  ___  ____  / / / /   |  / __ )(_)___ _____
           / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  / / __ `/ __ \
          / /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ / / /_/ / / / /
          \____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/_/\__,_/_/ /_/
              /_/
                  openHAB 2.4.0-1 (Release Build)


Looking for a place to get started? Check out 'sudo openhabian-config' and the
documentation at https://www.openhab.org/docs/installation/openhabian.html
The openHAB dashboard can be reached at http://openHABianPi:8080
To interact with openHAB on the command line, execute: 'openhab-cli --help'

/etc/openhab2/scripts/logviewer.sh: line 3: /etc/openhab2/html/events.html: Permission denied
/etc/openhab2/scripts/logviewer.sh: line 5: /etc/openhab2/html/events.html: Permission denied
/etc/openhab2/scripts/logviewer.sh: line 6: /etc/openhab2/html/events.html: Permission denied
/etc/openhab2/scripts/logviewer.sh: line 7: /etc/openhab2/html/events.html: Permission denied
/etc/openhab2/scripts/logviewer.sh: line 8: /etc/openhab2/html/events.html: Permission denied
/etc/openhab2/scripts/logviewer.sh: line 9: /etc/openhab2/html/events.html: Permission denied
/etc/openhab2/scripts/logviewer.sh: line 10: /etc/openhab2/html/events.html: Permission denied
/etc/openhab2/scripts/logviewer.sh: line 11: /etc/openhab2/html/events.html: Permission denied
/etc/openhab2/scripts/logviewer.sh: line 12: /etc/openhab2/html/events.html: Permission denied

ok Folks i got it!
It was as problem with the right of the written events.html
My fault was:
After i created the script i tested it from the shell, so there iam “openhabian” user
But OpenHab is “openhab” user and therefore “openhab” can overwrite the file.

before it was openhabian.openhabian so openhab can´t write it
so i have to change it with

chown openhab events.html

to:

-rw-r--r--  1 openhab    openhabian 12420 Feb  5 20:31 events.html

an it does the Job!!!

Thank you all bro´s!

1 Like

@Peter_Aschinger: In the 4th post I mention to use the openhabian-config tool and run “fix permissions”. Doing this should have solved the problem.

1 Like