Ruby-Skript zu telnet wechseln

Habe ich das folgende ruby-Skripts, das telnet Cisco-Geräte, die, telnet Cisco-Geräte, und führen Sie das Kommando "show int status err'.

require 'net/telnet'

C3550_20_PterraEst = "192.168.244.20" #Enter the IP address here

USER = "user" #Enter username here

PASS = "password" #Enter password here

ENABLE = "password" #Enter enable password here

print "Selezionare il piano [0-1-2-All]: ";

# get the input from the console, 
val1 = gets;
tn = Net::Telnet::new("Host" => C3550_20_PterraEst,
"Timeout" => 5,
"Prompt" => /Username/ )
tn.cmd("\n#{USER}") 
tn.cmd(PASS) 
tn.cmd("sh int status err\n") { |c| print c }
exit

Nun möchte ich, dass diejenigen, die Cisco-Geräte Ausgang (beim senden "show int status err') zugewiesen werden soll, zu einer Variablen in meinem script...ich besser erklären:

nehme an, dass das Kommando "show int status err' gibt diesen Wert zurück:

Int fa0/20
Int fa0/25

Ich will etwas tun, wie... variable1 = "Int fa0/20,Int fa0/25'
und später verwenden, variable1 in meinem Skript.

In welcher Art und Weise kann ich tun?

InformationsquelleAutor Marco | 2012-05-18

Schreibe einen Kommentar