Skip to content

Commit

Permalink
FS-11444: Capture return code from os.execute(); stop attempting to…
Browse files Browse the repository at this point in the history
… concat boolean/nil to error string.

os.execute() returns [3
variables](https://github.com/lua/lua/blob/f59e6a93c0ad38a27a420e51abf8f13d962446b5/lauxlib.c#L286).
Capture the 2nd (e.g. "exit") and 3rd (e.g. 0) in addition to the first
which would be merely `true` on success or `nil` on error.
  • Loading branch information
asiplas committed Oct 7, 2018
1 parent b5624ec commit 5e895b2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/lua/sound_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ else
-- Looks good, let's play some sound files
sound_base = session:getVariable('sounds_dir') .. '/en/us/callie/' .. stype .. '/' .. srate;
input_file = '/tmp/filez.txt';
res = os.execute('ls -1 ' .. sound_base .. ' > ' .. input_file);
freeswitch.consoleLog("INFO","Result of system call: " .. res .. "\n");
if ( res == 0 ) then
res, what, code = os.execute('ls -1 ' .. sound_base .. ' > ' .. input_file);
freeswitch.consoleLog("INFO","Result of system call: " .. what .. " " .. code .. "\n");
if ( res == true and what == 'exit' and code == 0 ) then
for fname in io.lines(input_file) do
freeswitch.consoleLog("NOTICE","Playing file: " .. fname .. "\n");
session:streamFile(sound_base .. '/' .. fname);
session:sleep(100);
end
else
freeswitch.consoleLog("ERR","Result of system call: " .. res .. "\n");
freeswitch.consoleLog("ERR","Result of system call: " .. what .. " " .. code .. "\n");
end
end

0 comments on commit 5e895b2

Please sign in to comment.