How to insert variables from lua into bash correctly? It is necessary for the script to transfer 2 variables, here is the code:
location /script { content_by_lua ' lua_arg1 = ngx.var.arg_arg1 lua_arg2 = ngx.var.arg_arg2 command = "/usr/bin/script.sh "..lua_arg1 ..lua_arg2 local handle = io.popen(command); local result = handle:read("*a"); handle:close(); ngx.print(result);';
}
Here is the query: localhost: 1501 / script5? Arg1 = 1234 & arg2 = 4321
Here is the bash script:
#!/bin/bash echo argument1 $1 echo argument2 $2
And here is the result:
argument1 12344321 argument2
It turns out that the variables "stuck together", how to transfer them individually to the script so that it would be like this:
argument1 1234 argument2 4321