Answer the question
In order to leave comments, you need to log in
What is the correct way to insert variables from lua into bash?
What is the correct way to insert variables from lua into bash?
You need to pass 2 variables to the script, 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);';
}
#!/bin/bash
echo argument1 $1
echo argument2 $2
Answer the question
In order to leave comments, you need to log in
Forgotten space
command = "/usr/bin/script.sh "..lua_arg1 .. " " .. lua_arg2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question