Audiovox P965 Datasheet Page 200

  • Download
  • Add to my manuals
  • Print
  • Page
    / 280
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 199
API Ruby class
197
while children > 1
Process.wait
children -= 1
end
Output might look a bit like:
user@host:~/$ ./dnsupdate.rb
10.0.0.4: Connecting...
10.0.0.4: Update command was sent.
10.0.0.4: Successfully updated DNS servers.
10.0.0.5: Connecting...
10.0.0.5: Update command was sent.
10.0.0.5: Successfully updated DNS servers.
... MORE OUTPUT ...
10.1.44.79: Successfully updated DNS servers.
user@host:~/$
The benefit of using Mikrotik's API is you can whip up a script to do something, then feed it a bunch of device IPs,
login user IDs and passwords from a database, then execute desired commands on ALL of the devices. Check
settings, change settings, monitor stats, etc.
Changing user group or deleting a user from a device
This shows how one can query a device for a list of configured users, then subsequently use API commands to
remove or alter settings for users (if they exist) referencing them by API .id:
## Retrieve a list of all users on a RouterOS device (with associated IDs):
users = {}
mt.get_reply_each('/user/getall') do |r, s|
if s.key?('!re') && s.key?('name')
users[s['name']] = {
:name => s['name'],
:group => s['group'],
:address => s['address'],
:comment => s['comment'],
:disabled => s['disabled'] == true,
:id => s['.id']
}
end
end
## Remove a specific named user (if found on the device):
mt.get_reply('/user/remove', "=.id=#{users['foo'][:id]}") if users.key?('foo')
## Make a named user (if found) an read-only user:
mt.get_reply('/user/set', "=.id=#{users['foo'][:id]}", "=group=read")
Page view 199
1 2 ... 195 196 197 198 199 200 201 202 203 204 205 ... 279 280

Comments to this Manuals

No comments