Here's an example that would go through all the robots and print the robot.cfg on screen. It needs to be run on a hub machine through NSA.
--functions
function get_robots(hub_address)
robots = {}
getrobots = nimbus.request(hub_address, "getrobots")
for x, robot in pairs(getrobots.robotlist) do
robots[robot.name] = robot.addr
end
return robots
end
function get_robot_cfg(robot_address)
pds_argument = pds.create()
pds.putString(pds_argument, "file", "robot.cfg")
getrobotinfo = nimbus.request(robot_address, "get_info")
if getrobotinfo ~= nil then
pds.putString(pds_argument, "directory", getrobotinfo["workdir"].."\\robot")
else
return 666
end
config, rc = nimbus.request(robot_address, "text_file_get", pds_argument)
if rc ~= 0 then
return 667
end
pds.delete(pds_argument)
return config["file_content"]
end
--main
nimbus.login("user", "pass")
hubs, rc = nimbus.request("hub", "gethubs")
if rc ~= 0 then
printf ("couldn't get hublist. rc: %d", rc)
end
for _, hub in pairs (hubs.hublist) do
robot_addresses = get_robots(hub.addr)
for _, robot_address in pairs (robot_addresses) do
robot_config = get_robot_cfg(robot_address)
if type(robot_config) == number then
printf ("%s error getting config: %d", robot_address, robot_config)
else
print (robot_config)
end
print("============================")
end
end
You need to deploy the "nsa" package to your hub. it will install under nim_folder\sdk\nsa. go there and run nsa.exe script_name.lua
-jon