tera term的ttl脚本使用方法
2011-12-20 00:00
1311 查看
介绍几个常用的命令
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. 通过log记录全程操作过程,最终通过比对log确认测试结果。
通过logopen/logclose命令来写log
logopen:
logopen filename 0 1 1
注:filename最好设成命令名,不通ttl脚本不要重复。也可以带执行的时间,
例如:Show_candidate_config_ 20110426-130939.log
方法如下:
gettime timestr "%Y%m%d-%H%M%S"
getdir mdir
sprintf2 filename '%s\ Show_candidate_config _%s.log' mdir timestr
logclose
:
logclose
c. 测试项作成时可能用到的命令
Pause:(暂停)
pause <time>Remarks:Pauses for <time> seconds.
Sendln:(发送命令并换行)
sendln <data1> <data2>....
Remarks:Causes Tera Term to send characters followed by a new-line character to the host.
Send:(发送命令)
send <data1> <data2>....
Remarks:Causes Tera Term to send characters to the host.
If <data> is a string, the string is sent to the host.
If <data> 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. 例如:按Tab键的命令是send #9
wait:(等待匹配的字符串出现)
wait <string1> [<string2> ...]
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.
注:使用这个命令是需要设置timeout时间,命令的返回结果保存在resault变量中,当resault为时,则为超时。Timeout 设置命令如下:
timeout=1 /*等号后面的值为整数,设为负则是无限等待*
waitln:(等待整行匹配的字符串出现)
waitln <string1> [<string2> ...]
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.
注意点同上 其他命令例如if,then,elseif,else,endif,goto等请参考help文件。
脚本作成的注意点
a. 不同的ttl脚本内指定的Log文件名不能重复。
b. 脚本的最后部分请清空测试环境,以便下一个ttl脚本执行。
c. 在执行比较缓慢的地方,例如连接机器时,请追加pause命令
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 1
;###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
;###run cmd
sendln "ls -l"
wait "#"
looptimes = looptimes + 1
endwhile
;###closelog
Logclose
;###disconnect
disconnect
closett
执行bat文件就可以运行ttl脚本了.
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. 通过log记录全程操作过程,最终通过比对log确认测试结果。
通过logopen/logclose命令来写log
logopen:
logopen filename 0 1 1
注:filename最好设成命令名,不通ttl脚本不要重复。也可以带执行的时间,
例如:Show_candidate_config_ 20110426-130939.log
方法如下:
gettime timestr "%Y%m%d-%H%M%S"
getdir mdir
sprintf2 filename '%s\ Show_candidate_config _%s.log' mdir timestr
logclose
:
logclose
c. 测试项作成时可能用到的命令
Pause:(暂停)
pause <time>Remarks:Pauses for <time> seconds.
Sendln:(发送命令并换行)
sendln <data1> <data2>....
Remarks:Causes Tera Term to send characters followed by a new-line character to the host.
Send:(发送命令)
send <data1> <data2>....
Remarks:Causes Tera Term to send characters to the host.
If <data> is a string, the string is sent to the host.
If <data> 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. 例如:按Tab键的命令是send #9
wait:(等待匹配的字符串出现)
wait <string1> [<string2> ...]
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.
注:使用这个命令是需要设置timeout时间,命令的返回结果保存在resault变量中,当resault为时,则为超时。Timeout 设置命令如下:
timeout=1 /*等号后面的值为整数,设为负则是无限等待*
waitln:(等待整行匹配的字符串出现)
waitln <string1> [<string2> ...]
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.
注意点同上 其他命令例如if,then,elseif,else,endif,goto等请参考help文件。
脚本作成的注意点
a. 不同的ttl脚本内指定的Log文件名不能重复。
b. 脚本的最后部分请清空测试环境,以便下一个ttl脚本执行。
c. 在执行比较缓慢的地方,例如连接机器时,请追加pause命令
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 1
;###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
;###run cmd
sendln "ls -l"
wait "#"
looptimes = looptimes + 1
endwhile
;###closelog
Logclose
;###disconnect
disconnect
closett
执行bat文件就可以运行ttl脚本了.
相关文章推荐
- tera term的ttl脚本使用方法
- 脚本、视图-最简单的查询表空间的使用量、剩余量的方法-by小雨
- 使用VBS访问外部文本文件一些方法和脚本实例代码
- [Android]Recovery调用外部Shell脚本,Shell脚本使用ui_print方法
- 使用Python脚本生成随机IP的简单方法
- scp 在脚本中使用输入密码的解决方法
- ftp在shell脚本中的使用方法
- mysql备份脚本 mysqldump使用方法详解
- 在linux下定时执行PHP脚本(定时执行crontab使用方法详解)
- 使用jQuery动态加载js脚本文件的方法
- Ecshop JS脚本引入方法insert_scripts函数使用和新增
- 使用js脚本定时更新页面的方法
- 如何使用Linux的Crontab定时执行PHP脚本的方法
- MongoDB服务端JavaScript脚本使用方法
- 关闭ssh后仍然运行程序脚本的方法 -- 使用 screens
- 使用shell脚本取出服务器图片的方法
- C++中使用Lua脚本 和lua中调用c的方法
- jquery.slides.js 幻灯片脚本使用方法
- 使用JavaScript脚本无法直接改变Asp.net中Checkbox控件的Enable属性的解决方法
- crontab中使用环境变量的方法(手动执行shell脚本可以,在定时任务中不行)