You can use the uuid_dump command to get all the channel variables and values. Here's some rudimentary code which accepts the uuid as an argument:
-- Lua has no split function, so we need to create one
function string:split( inSplitPattern, outResults )
if not outResults then
outResults = {}
end
local theStart = 1
local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
while theSplitStart do
table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) )
theStart = theSplitEnd + 1
theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
end
table.insert( outResults, string.sub( self, theStart ) )
return outResults
end
api = freeswitch.API()
uuid = argv[1]
-- uuid_dump gets all vars for a particular channel
res = api:execute('uuid_dump',uuid)
freeswitch.consoleLog('INFO',"Complete vars list: " .. res .. "\n")
-- lines is a table, one row per var: val pair
lines = string.split(res,"\n")
for i=1,#lines do
-- check for variable name using pattern match
-- Adjust the pattern to whatever you are trying to find
myPattern = 'variable_'
if string.match(lines[i], myPattern) then
varval = string.split(lines[i],": ")
freeswitch.consoleLog("NOTICE","Variable '" .. varval[1] .. "' contains '" .. varval[2] .. "'\n")
end
end
I don't know if this is the most efficient way of doing what you're trying to do but it does demonstrate the power and flexibility of Lua and FreeSWITCH API's like uuid_dump.