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. 

-MC

On Wed, Mar 2, 2016 at 12:05 PM, Oleg Stolyar <olegstolyar@gmail.com> wrote:
Hi guys,

is there a way to find all the session variable with a certain name pattern in lua?

For example I need to find all the session variables whose names start with "bla_"

As an alternative is there a way to iterate over all the session variables?  Then I can just do that and find the variables I need this way.

_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com

FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org