lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

You can try luabash[1] wish is a bash modulue to interact with lua.
Its possible to use lua in bash (even the interative prompt) and load
bash script within lua. I use it at work to extend bash scripts.


For your example create a lua file;
--Lua scipt
function redirections()
   repeat
      a=io.read()
      if a~=nil then print("xx"..a.."xx") end
   until a==nil
end
-- We need to register the function
bash.resgister("redirections")

# Now from bash
# Enable the bash module
enable -f luabash.so
# Load the lua scrpit
luabash load ./script.lua

cat <<EOF | redirections | sed 's,xx,yy,g' # here is the redirictions function being called
line one
line two
line three
EOF
# Done
You can use bash.call("sed /thing/thang( file.txt)") from lua.

Check the examples [2] 
I can write more documentation if you want.

[1] https://github.com/masterkorp/LuaBash
[2] https://github.com/masterkorp/LuaBash/tree/master/doc


--
Regards,
Alfredo Palhares