tera term的ttl脚本使用方法[转]
(2014-02-24 13:21:57)http://hi.baidu.com/��jiji_555/blog/item/b41a66097db616b92fddd4e8
介绍几个常用的命令
a. 通过Tera Term连接PFC所在的机器以及断开连接
通过TTL的connect/disconnect命令实现
Connect:
connect '192.168.137.27 /ssh /auth=password /user=username /passwd= passwd'
注:其中username是用户名,passwd是密码
Disconnect:
disconnect
注:disconnect后面指定参数,这样就不弹出确认框了。
b.
通过logopen/logclose命令来写log
logopen:
logopen filename 0 1 1
注:filename最好设成命令名,不通ttl脚本不要重复。也可以带执行的时间,
例如:Show_candidate_config_
gettime timestr "%Y%m%d-%H%M%S"
getdir mdir
sprintf2 filename '%s\ Show_candidate_config
_%s.log' mdir
c.
Pause:(暂停)
Sendln:(发送命令并换行)
sendln ....
Remarks:Causes Tera
Term to send characters followed by a new-line character to the
host.
Send:(发送命令)
send ....
Remarks:Causes Tera Term to send characters to the host.
If is a string, the string is sent to the
host.
If is an integer, its lowest-order byte (0-255) is
regarded as an ASCII code of the character, and the character is
sent to the
host.
wait:(等待匹配的字符串出现)
wait [ ...]
Remarks:Pauses until
one of the character strings is received from the host, or until
the timeout occurs. Maximum number of the strings is
10.
waitln:(等待整行匹配的字符串出现)
waitln [ ...]
Remarks:Pauses until a
line which contains one of the character strings is received from
the host, or until the timeout occurs. Maximum number of the
strings is
10.
注意点同上
脚本作成的注意点
a.
b.
c.
d.
e.
使用例子:
1,在window下创建bat文件,
"C:\Program
Files\teraterm\ttpmacro.exe" "D:\My Kownhow\TTL\test.ttl"
exit
2,生产ttl脚本文件test.ttl
;###connect host
connect '172.28.92.23 /ssh /auth=password /user=root
/passwd=password'
pause
;###create log
gettime logstr "log-%Y%m%d-%H%M%S.txt"
getdir curdir
sprintf '%s\%s' curdir logstr
filename = inputstr
logopen filename 0 1 1
logwrite 'Log start'#13#10
looptimes = 1 ;
while looptimes < 11
looptimes = looptimes + 1
endwhile
;###closelog
Logclose
;###disconnect
disconnect
closett
执行bat文件就可以运行ttl脚本了.