Cisco デバイスに telnet で接続し、Cisco デバイスに telnet で接続し、コマンド 'show int status err' を実行する次の Ruby スクリプトを作成しました。
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
ここで、これらの Cisco デバイスの出力 (「show int status err」を送信したとき) をスクリプト内の変数に割り当てる必要があります...もっと詳しく説明します。
コマンド「show int status err」が次の値を返すとします。
Int fa0/20 Int fa0/25
次のようなことをしたい... variable1 = 'Int fa0/20,Int fa0/25' その後、スクリプト内で variable1 を使用します。
魔女のように私はできますか?