openresty / openresty/lua-nginx-module

No way to run command, and get both it's output and it's return code

Open
#779 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.8k
Forks
2.1k
Avg merge
6h 1m
Merged PRs (30d)
6

Description

I need, in my lua script, to run a shell command. Then, I need to check it succeeded, using it's retval, and get it's stdout.
To achieve that, I have this code:

handler = assert(io.popen("echo my command is here"))
data = handler:read("*a")
succeeded, error_msg, retcode = handler:close()

"data" indeed gets the command output, but "succeeded" is always nil.
"error_msg" is "No child processes", and "retcode" is 10

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Lua snippet using io.popen, handler:read("*a"), and handler:close(), recording the stdout and return values. Trace these entry points to determine whether both command output and the return code can be exposed; done means the documented behavior or implementation clearly provides both values.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.