AnsweredAssumed Answered

string.find (simple Lua Problem)

Question asked by MattGruber on May 25, 2010
Latest reply on May 14, 2012 by MattGruber

Hi!

 

Sorry, but I still coulndt manage it to threw my Python-ish thinking out of the window in favor of LUA :-P

I assume its a simple question, but I didnt see it at the moment.

 

I just want to string.find the domain out of a hub-address

 

Did the following (not stylish, but seems to work till string.find)

 

nimbus.log(3,"##--SCRIPT_DEBUG: funcGetRobots()")
nimbus.log(3,"##--SCRIPT_DEBUG: Domain: "..HubRobot['Domainname'])
    
local foundRobots = {}

for key,val in pairs(DomainHubs) do
-- Durch die Hubs laufen und Robots einsammeln
nimbus.log(3,"##--SCRIPT_DEBUG: funcGetRobots(): DomainHubs->Key "..key)
-- Finde den Domaenennamen im Key
  if string.find(key,HubRobot['Domainname']) ~= nil then
  -- gefunden
  nimbus.log(3,"##--SCRIPT_DEBUG: Hub in der Domaene gefunden")
  nimbus.log(3,"##--SCRIPT_DEBUG: Domain: "..HubRobot['Domainname'])
  nimbus.log(3,"##--SCRIPT_DEBUG: HubFQDN: "..key)
  nimbus.log(3,"##--SCRIPT_DEBUG: nimbus.request: GetRobots")
  local foundRobots,rc = nimbus.request(key,"getrobots")
  if rc == 0 then
   -- getrobots war o.k.
   DomainHubs[key][2]=foundRobots.addr
  else
   -- getrobots ging schief
   nimbus.log(3,"##--SCRIPT_DEBUG: GetRobots !!! FEHLER !!! rc ~= 0")
  end --if
else
  nimbus.log(3,"##--SCRIPT_DEBUG: string.find == nil")
end --if
end --for

 

 

with following output in my log

 

May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: funcGetRobots()
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: Domain: Metzler-domain-test
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: funcGetRobots(): DomainHubs->Key /Metzler-domain-test/wvast-nms02-hub/wvast-nms02/hub
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: string.find == nil
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: funcGetRobots(): DomainHubs->Key /Metzler-domain-test/wvast-nms01-hub/wvast-nms01/hub
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: string.find == nil
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: funcGetRobots(): DomainHubs->Key /Metzler-domain-test/lvasp-nmsport01-hub/lvasp-nmsport01/hub
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: string.find == nil
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: funcGetRobots(): DomainHubs->Key /Metzler-domain/lvast-nms01-hub/lvast-nms01/hub
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: string.find == nil
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: funcGetRobots(): DomainHubs->Key /Metzler-domain-test/wvasp-nmsssl01-hub/wvasp-nmsssl01/hub
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: string.find == nil
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: funcGetRobots(): DomainHubs->Key /Metzler-domain-test/wvasp-nmsexec01-hub/wvasp-nmsexec01/hub
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: string.find == nil
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: funcGetRobots(): DomainHubs->Key /nmstest/wvast-nmsjhu2/wvast-nmsjhu2/hub
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: string.find == nil
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: funcGetRobots(): DomainHubs->Key /Metzler-domain-test/wvasp-nmsssl02-hub/wvasp-nmsssl02/hub
May 25 13:42:14:109 nsa: ##--SCRIPT_DEBUG: string.find == nil

 

 

Keys he should get the find with ~= nil. even checked if type is correct bot (key + HubRobot['Domainname']) says string (what else...)

 

hEHHE I think there are still one or two errors but, at least I would expect he runs into the "-- gefunden" -Part of the if-stuff

 

cheers

Matthias

Outcomes