나는 시스코 장비에 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
가 지금은 그 시스코 장치의 출력이 (내가 보낼 때 '내부 상태 ERR을 보여') 내 스크립트 내부 변수에 할당해야한다는 싶어 ... 내가 더 잘 설명 :
명령 있다고 가정 ' 쇼 INT 상태 ERR '는이 값을 반환지능에 의해 Fa0/20 지능에 의해 Fa0/25
내가 ... 변수 1 = 같은 무언가를 원하는'Int 수에 의해 Fa0/20, Int 수에 의해 Fa0/25 ' 및 나중에 내 스크립트에서 variable1을 사용하십시오.
마녀 방법으로 할 수 있습니까?
다음과 같이하면됩니다. tn.cmd ("sh int status err \ n") {| @c | print @c} 오류가 발생합니다; – Marco