AnsweredAssumed Answered

LUA -- parsing text into a table

Question asked by mipnix on Aug 19, 2012
Latest reply on Aug 20, 2012 by 1_keithk



I am trying to parse a list of profiles, from the net_connect probe, and place them into a table. I apparently don't understand the logic of my request, since the table value returns as nil, when I print it. My code is below. Any suggestions are appreciated.


Kind regards.


--Global declarations all_profile_names = {}  --Connect to probe. Edit this line with the address of your hub you wish to query addr = "/NIX/PrimaryHUB/hub1/controller"  --Command to request configuration of probe command = "probe_config_get"  --Build PDS answer file when probe_config_get asks for probe name args = pds.create() pds.putString(args, "name", "net_connect")  --Send request and store data in h_resp{} h_resp,rc = nimbus.request(addr, command, args) defaults = h_resp["/setup/default_host"] full_profiles = h_resp["/profiles"]  print("Test1") for k, v in pairs (h_resp) do    if substr(k, "/profiles/%a") then -- trying to pull just the names section       all_profile_names = string.sub("/profiles/%a", 10) --assign names to all_profile_names table    end end print("Test2") for k,v in pairs(all_profile_names) do    print (k.." : ", v)--this returns: end print(all_profile_names[1])