How to access/read value of a shell script via lua

Hello, I am making a custom app in openWrt using luasrc structure. I have a shell script in which various functions are defined and I am able to execute those functions using os.execute from my lua script. But now I want to access/read the value of the variable in my shell script. I tried using io.popen , I just used the example code for io.popen and it is throwing an error ./example.lua: line 1: syntax error near unexpected token (' ./example.lua: line 1: f = assert (io.popen ("ls -l"))'

Is there a way to read the value of a variable which is in shell script from lua script.

I'm sure there are better ways in lua to iterate over/get a list of a directory content than running ls -l over it.

Before the transition to client-side rendering, the luci-app-advanced-reboot used to pull a lot of information from various shell commands into the lua file, so maybe this will be helpful.

Thanks for your reply!!!
Your suggestion worked for me

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