tips/teraterm

Last-modified: 2007-03-09 (金) 23:38:44

ちょーてきとーマクロ

ショートカットのリンク先の後ろにオプションを付けるとマクロを自動実行してくれるよ
"C:\Program Files\teraterm\ttermpro.exe" /M="c:\hoge\testmacro.ttl /KS=EUC /KR=SJIS
/KS・・・送信漢字コード
/KR・・・受信漢字コード

; Sample macro for Tera Term
;  Telnet login
; open Tera Term
;   command line = 'TERATERM myhost.mydomain' (telnet)
connect '192.168.0.100'
timeout = 15
; set username
UsernamePrompt = 'login:'
Username = 'root'
PasswordPrompt = 'Password:'
CommandPrompt = '#'
CommandPrompt2 = '>'
LoginError = 'Login incorrect'
; get password from file
;getpassword 'password.dat' 'mypassword' Password
LogFileName=''
LogFileName='C:\systemlog\'
getdate Today
strconcat LogFileName Today
strconcat LogFileName '_hoge_netstat.log'
logopen LogFileName 0 1
; login
:EntUser
wait   UsernamePrompt
sendln Username
:EntPass
wait   PasswordPrompt
passwordbox 'Enter Password!!' 'Password'
sendln inputstr
wait   CommandPrompt LoginError
if result = 0 goto Exit
if result = 2 goto EntUser
sendln 'while :'
wait   CommandPrompt2
if result = 0 goto Exit
sendln 'do'
wait   CommandPrompt2
if result = 0 goto Exit
sendln 'date'
wait   CommandPrompt2
if result = 0 goto Exit
sendln 'netstat -an'
wait   CommandPrompt2
if result = 0 goto Exit
sendln 'ps -ef'
wait   CommandPrompt2
if result = 0 goto Exit
sendln 'echo ""'
wait   CommandPrompt2
if result = 0 goto Exit
sendln 'sleep 60'
wait   CommandPrompt2
if result = 0 goto Exit
sendln 'done'
:Exit
; OK, auto login complete.