Audiovox P965 Arkusz Danych Strona 194

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 280
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 193
API Ruby class
191
>>> 'comment=' (8)
>>> '.tag=2' (6)
>>> END-OF SENTENCE
<<< '/cancel' (7)
<<< '=tag=2' (6)
<<< END-OF-SENTENCE
>>> '!trap' (5)
>>> 'category=2' (10)
>>> 'message=interrupted' (19)
>>> '.tag=2' (6)
>>> END-OF SENTENCE
=== TRAP: 'interrupted'
>>> '!done' (5)
>>> '.tag=3' (6)
>>> END-OF SENTENCE
>>> '!done' (5)
>>> '.tag=2' (6)
>>> END-OF SENTENCE
Command (/quit to end):
Using the Gem in Code
Execute an API command that returns endless replies until canceled
Suppose I wish to monitor traffic on an interface using the /interface/monitor-traffic command for 10
seconds--or in other words, because devices usually send responses to this command once every second, I want to
listen for and receive 10 replies, then cancel the command:
<nowiki>
#!/usr/bin/env ruby
require 'rubygems'
require 'mtik'
# Be verbose in output
MTik::verbose = true
# Connect to the device:
connection = MTik::Connection.new :host => '10.0.0.1', :user => 'admin', :pass => 'password'
# We are going to send a "monitor-traffic" command that will keep sending
Przeglądanie stron 193
1 2 ... 189 190 191 192 193 194 195 196 197 198 199 ... 279 280

Komentarze do niniejszej Instrukcji

Brak uwag