2004.11.25 Thursday
TeraTermマクロ:Command入力支援マクロ(2)
mainのマクロから機能ごとにインクルードファイルを呼び出すことにより、拡張性が高くなっていると思います。うまく作れば、オペレータレベルの人でも運用することが可能になると思います。
但し、あまり複雑にするとメンテナンスが大変になる気も。。。
timeout = 10
:loop
wait "!END" "!CPU" "!INT" "!CNF" "!HELP"
if result=0 then
goto loop
elseif result=1 then
end
elseif result=2 then
sendln
sendln "sh proc cpu"
elseif result=3 then
sendln
include "int.ttl"
elseif result=4 then
sendln
include "cnf.ttl"
elseif result=5 then
sendln
sendln "!!! HELP !!!"
sendln "! !+CNF:CONFIGURATION"
sendln "! !+INT:INTERFACE"
endif
goto loop
<インクルード1(cnf.ttl)>
timeout = 10
sendln "enable"
wait "Password:"
sendln "pass"
wait "Router#"
:MAC1
wait "!END" "!RAM" "!RUN" "!HELP"
if result=0 then
goto MAC1
elseif result=1 then
sendln
sendln "disable"
exit
elseif result=2 then
sendln
sendln "sh run"
elseif result=3 then
sendln
sendln "sh conf"
elseif result=4 then
sendln
sendln "!!! HELP !!!"
sendln "! !+RAM:NVRAM-CONFIG"
sendln "! !+RUN:RUNNING-CONFIG"
endif
goto MAC1
<インクルード2(int.ttl)>
timeout = 10
:MAC2
wait "!END" "!ETH" "!SER" "!HELP"
if result=0 then
goto MAC2
elseif result=1 then
sendln
exit
elseif result=2 then
sendln
sendln "sh int E0"
elseif result=3 then
sendln
sendln "sh int S0"
elseif result=4 then
sendln
sendln "!!! HELP !!!"
sendln "! !+ETH:Ethernet0"
sendln "! !+SER:Serial0"
endif
goto MAC2
但し、あまり複雑にするとメンテナンスが大変になる気も。。。
timeout = 10
:loop
wait "!END" "!CPU" "!INT" "!CNF" "!HELP"
if result=0 then
goto loop
elseif result=1 then
end
elseif result=2 then
sendln
sendln "sh proc cpu"
elseif result=3 then
sendln
include "int.ttl"
elseif result=4 then
sendln
include "cnf.ttl"
elseif result=5 then
sendln
sendln "!!! HELP !!!"
sendln "! !+CNF:CONFIGURATION"
sendln "! !+INT:INTERFACE"
endif
goto loop
<インクルード1(cnf.ttl)>
timeout = 10
sendln "enable"
wait "Password:"
sendln "pass"
wait "Router#"
:MAC1
wait "!END" "!RAM" "!RUN" "!HELP"
if result=0 then
goto MAC1
elseif result=1 then
sendln
sendln "disable"
exit
elseif result=2 then
sendln
sendln "sh run"
elseif result=3 then
sendln
sendln "sh conf"
elseif result=4 then
sendln
sendln "!!! HELP !!!"
sendln "! !+RAM:NVRAM-CONFIG"
sendln "! !+RUN:RUNNING-CONFIG"
endif
goto MAC1
<インクルード2(int.ttl)>
timeout = 10
:MAC2
wait "!END" "!ETH" "!SER" "!HELP"
if result=0 then
goto MAC2
elseif result=1 then
sendln
exit
elseif result=2 then
sendln
sendln "sh int E0"
elseif result=3 then
sendln
sendln "sh int S0"
elseif result=4 then
sendln
sendln "!!! HELP !!!"
sendln "! !+ETH:Ethernet0"
sendln "! !+SER:Serial0"
endif
goto MAC2