summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-01-01 16:21:30 +0000
committerTed Trask <ttrask01@yahoo.com>2013-01-01 16:21:30 +0000
commit658e5eb731ad567ef2d8ca6add2c1decbc3a2840 (patch)
tree98ef6de165eedaec43129dfea5dcac53a31e7c7e /lib
parentf5e04936c08e10a9c39f091f9dc420c89472cb18 (diff)
downloadacf-core-658e5eb731ad567ef2d8ca6add2c1decbc3a2840.tar.bz2
acf-core-658e5eb731ad567ef2d8ca6add2c1decbc3a2840.tar.xz
lib/modelfunctions: Add stdin input to run_executable function
Diffstat (limited to 'lib')
-rw-r--r--lib/modelfunctions.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/modelfunctions.lua b/lib/modelfunctions.lua
index 4f99780..54e9fb4 100644
--- a/lib/modelfunctions.lua
+++ b/lib/modelfunctions.lua
@@ -240,18 +240,26 @@ end
-- output will never be nil
-- errtxt will be nil for success and non-nil for failure
-- if include_err, then stderr will be prepended to stdout (if executable doesn't fail)
-run_executable = function(args, include_err)
+run_executable = function(args, include_err, input)
local output = ""
local errtxt
local res, err = pcall(function()
-- For security, set the path
posix.setenv("PATH", "/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin")
- args.stdin = "/dev/null"
+ if input then
+ args.stdin = subprocess.PIPE
+ else
+ args.stdin = "/dev/null"
+ end
args.stdout = subprocess.PIPE
args.stderr = subprocess.PIPE
local proc, errmsg, errno = subprocess.popen(args)
if proc then
+ if input then
+ proc.stdin:write(input)
+ proc.stdin:close()
+ end
local out = {}
local err = {}
function readpipes()