[SOLVED] Running .sh script in LuCi

Hello everyone,

I have a /usr/lib/lua/luci/controller/my_page.lua which produces the My Page menu entry and a /pr_home/my_page.sh script that produces the html page I want to see when I clic My Page.

All works fine, but currently I have to manually run the .sh script with luci-app-commands before clicking the menu; so I spent some time surfing (without success) the forum and the web to find a way to directly run it when I clic My Page: is it possible? Do you have any hint?

Thanks a lot.

can we see what you've got ? this is a legacy app (luci-compat) ? or are you running ancient firmware ?

In either case, please provide the contents of the my_page.lua controller above.

Running 23.05.5; content of my_page.lua is as follows:

module("luci.controller.my_page", package.seeall)
function index()
    entry({"admin", "my_page"}, template("my_page"), "My Page", 70)
end

Thanks

so, what you are try to do is call your script while loading the page ?

Its been a while but i think something like this should still work

create a lua library in /usr/lib/lua/mypage/my_page.lua

module("mypage.my_page", package.seeall)

function on_load()
        os.execute("/pr_home/my_page.sh")
end

at the top in your /view/my_page.htm add the require

<% 
local s = require "mypage.my_page"
s.on_load()
%>
1 Like

so, what you are try to do is call your script while loading the page ?

Yes; I'll try and let you know.

It works, thanks for your help.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.