9951 explained code solutions for 126 technologies


nginx-luaHow execute shell command with Lua


If you want to capture command output, you should use io.popen instead.

server {
  location / {
    content_by_lua_block {
      os.execute('echo 1 > /tnp/hi')
    }
  }
}ctrl + c
content_by_lua_block

nginx-lua module directive to specify block of Lua code

os.execute

executes given shell command

echo 1 > /tnp/hi

random shell command