![TCL脚本实例+检查IP的脚本源码.doc_第1页](http://file.renrendoc.com/FileRoot1/2020-1/22/58f75db9-2cd7-42b7-8c7c-db6aa0df106c/58f75db9-2cd7-42b7-8c7c-db6aa0df106c1.gif)
![TCL脚本实例+检查IP的脚本源码.doc_第2页](http://file.renrendoc.com/FileRoot1/2020-1/22/58f75db9-2cd7-42b7-8c7c-db6aa0df106c/58f75db9-2cd7-42b7-8c7c-db6aa0df106c2.gif)
![TCL脚本实例+检查IP的脚本源码.doc_第3页](http://file.renrendoc.com/FileRoot1/2020-1/22/58f75db9-2cd7-42b7-8c7c-db6aa0df106c/58f75db9-2cd7-42b7-8c7c-db6aa0df106c3.gif)
![TCL脚本实例+检查IP的脚本源码.doc_第4页](http://file.renrendoc.com/FileRoot1/2020-1/22/58f75db9-2cd7-42b7-8c7c-db6aa0df106c/58f75db9-2cd7-42b7-8c7c-db6aa0df106c4.gif)
![TCL脚本实例+检查IP的脚本源码.doc_第5页](http://file.renrendoc.com/FileRoot1/2020-1/22/58f75db9-2cd7-42b7-8c7c-db6aa0df106c/58f75db9-2cd7-42b7-8c7c-db6aa0df106c5.gif)
免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
TCL脚本实例: 检查IP的脚本 1 脚本源码 本脚本系谭勇书写运行结果如下:rootMeil89 bin# ./IP.tcl -f ./cfg/ip_R2.6.0_DRM.cfg= Ping 3 failed! = Ping 6 failed! = Ping 7 failed! = Ping 9 failed! = Ping 6 failed! = Ping 7 failed! = Ping 9 failed! = Ping 1 failed! =invalid IP 10.56.53/31Invalid ip string: 10.56.53/31!= Totally 52 ping successfully as below: 0 1 2 6 0 1 2 3 8 1 2 5 8 1 2 5 6 2 00 01 0 1 2 3 8 1 2 5 8 1 2 5 6 0 0 1 3 4 0 1 7 8 0 1 0 3 7 8 0 0 0 1= Can not ping 8 host as below: 3 6 7 9 6 7 9 1rootMeil89 bin# rootMeil89 bin# ./IP.tcl ping 1-70= Ping 3 failed! = Ping 4 failed! = Ping 7 failed! = Totally 17 ping successfully as below: 1 2 5 6 8 9 0 1 2 3 4 5 6 7 8 9 0= Can not ping 3 host as below: 3 4 7rootMeil89 bin# 今后我们将对这个脚本进行学习.# !/usr/bin/tclsh# !/bin/bash# exec tclsh $0 $set auto_path lappend auto_path file dirname info script ./libpackage require ftppackage require Expectset Usage Usage: n ttclsh $argv0 -f iplist.cfg ?blockn ttclsh $argv0 ping startIp-endIpn ntExample: n tttclsh $argv0 -f iplist.cfg CMS n tttclsh $argv0 ping 0-65n # Define the global variablesset failPing set pingSuccess set flag noset ipListFile set ipBlock set ipList set tmpArgv split string trim join $argv if llength $tmpArgv = 2 set flag lindex $tmpArgv 0 if lindex $tmpArgv 0 = -f set ipListFile lindex $tmpArgv 1 if llength $tmpArgv = 3 set ipBlock lindex $tmpArgv 2 elseif string equal -nocase $flag ping lappend ipList list NULL lindex $tmpArgv 1 else puts $Usage exit else puts $Usage exit# Get the host listif $ipListFile != if $ipBlock = set listBlock getProfile $ipListFile ALL else set listBlock $ipBlock foreach block $listBlock if string equal -nocase $block error | string equal -nocase $block args continue set listKey getProfile $ipListFile $block ALL ONLY_KEY # Insert the key to the ipList like: blockName KeyName foreach key $listKey if string equal -nocase $key error continue lappend ipList list $block $key # Handle each listforeach ip_list $ipList set block lindex $ip_list 0 set ipStr lindex $ip_list 1 set ipKey $ipStr if $block != NULL set ipStr getProfile $ipListFile $block $ipKey if string equal -nocase $ipStr error continue # Get the IP according to the ipStr if set g_ipList GetIP $ipStr = -1 puts Invalid ip string: $ipStr! continue # Ping the IP set result # BadIp: set num 0 foreach ip $g_ipList # Ping the host if PingHost $ip 1 != 0 lappend failPing $ip incr num regexp (0-9+).(0-9+).(0-9+).(0-9+) $ip - p1 p2 p3 p4 append result $p4 puts = Ping $ip failed! = else lappend pingSuccess $ip #puts = Ping $ip successfully! = # Write the result if $block != NULL if $num = 0 set result # OK set tmpStr format %-30s%s string trimright $ipStr $result setProfile $ipListFile $block $ipKey $tmpStr if llength $pingSuccess = 1 puts n= nTotally llength $pingSuccess
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 儿童读物及读后感8篇
- 全国交通安全反思日演讲稿(31篇)
- 小班语言教案:小鸭找妈妈
- 供电大楼宿舍购房合同
- 2024年连锁餐饮项目经营分析报告
- 2024年智能电网变电设备项目投资建议书
- 客户关系管理-问答题及参考答案 苏朝晖
- 自我职业生涯规划书
- 高中班级工作总结范文
- GB∕T 38126-2019 电子商务交易产品信息描述 茶叶
- 初中物理实验列表
- 贵州省六盘水市六枝特区2020年部编版小升初考试语文试卷.docx
- 学校中考英语听说考试考场应急预案
- 铝单板幕墙工程施工方案
- 通信行业传输管线工程专业知识汇编
- 药物外渗处理指引
- 应用回归分析课后习题第3章11题
- 关于泰勒斯威夫特的ppt
- 车辆管理所车管业务告知制度
- 美国经典短篇小说The-Lottery完整评析
- 德州村镇征地补偿安置实施办法
评论
0/150
提交评论