| C:\snml2019\var\var_nms1.txt |
001 | var {myvar1} value {test1} |
002 | var {myvar2} value number {(1+2)*3/4-5} |
003 | var {myvar3} value datetime |
004 | |
005 | var {myvar4} copy var {myvar1} |
006 | var {myvar5} copy var {myvar2} |
007 | var {myvar6} copy var {myvar3} after {5} bytes length {5} |
008 | |
009 | var {myvar4} add {2} |
010 | var {myvar5} add number {1} |
011 | var {myvar6} replace {-} with {.} |
012 | |
013 | var {myvar7} copy var {myvar5} |
014 | var {myvar7} adjust length {10} align {right} |
015 | |
016 | screen.text at point {10} {30} string {myvar1 = [~myvar1~]} |
017 | screen.text at point {10} {50} string {myvar3 = [~myvar2~]} |
018 | screen.text at point {10} {70} string {myvar3 = [~myvar3~]} |
019 | screen.text at point {10} {90} string {myvar4 = [~myvar4~]} |
020 | screen.text at point {10} {110} string {myvar5 = [~myvar5~]} |
021 | screen.text at point {10} {130} string {myvar6 = [~myvar6~]} |
022 | screen.text at point {10} {150} string {myvar7 = [~myvar7~]} |
023 | |
024 | run.end |
#screen.text语句见第二章屏幕部分。
| C:\snml2019\screen\screen_nms1.txt |
001 | screen.set font {华文行楷} size {40} |
002 | screen.text at point {140} {60} string {简单网络管理语言} |
003 | |
004 | screen.set font {Arial} size {12} |
005 | screen.text at point {180} {100} string { Simple Network Management Language } |
006 | screen.line from point {10} {120} to point {630} {120} |
007 | |
008 | screen.play midi {CDEFGAB cdefgab 1234567 1 2 3 4 5 6 7} |
009 | |
010 | var {x} value { 10} |
011 | var {y} value { 300} |
012 | |
013 | macro.call {draw_ladybird} |
014 | |
015 | screen.text at point {200} {350} string {版本:snml8.13(ladybird)} |
016 | |
017 | screen.text at point {200} {400} string {技术支持邮箱1:snml2019@protonmail.com} |
018 | screen.text at point {200} {425} string {技术支持邮箱2:snml2019@hotmail.com} |
019 | screen.text at point {10} {180} string {术语1:简单网络管理协议S N M P( Simple Network Management Protocol )} |
020 | screen.text at point {10} {230} string {术语2:简单网络管理语言 S N M L ( Simple Network Management Language )} |
021 | |
022 | screen.line from point {50} {220} to point {630} {220} |
023 | screen.line from point {50} {265} to point {630} {265} |
024 | screen.line from point {30} {290} to point {630} {290} |
025 | screen.line from point {130} {315} to point {630} {315} |
026 | run.set loglevel {info} |
027 | |
028 | screen.speak {1、什么是简单网络管理协议S N M P( Simple Network Management Protocol )?} |
029 | |
030 | screen.text at point {50} {205} string {简单网络管理协议是可以管理不同厂家网络设备的简单通讯协议。} |
031 | screen.text at point {50} {250} string {简单网络管理语言是一种类自然语言的脚本语言,它采用snmp、telnet、ping、dns、arp、ssh、} |
032 | screen.text at point {30} {275} string {tcp、udp、web等协议与网络设备的互动,内置了smtp协议用于告警等邮件的发送,} |
033 | screen.text at point {130} {300} string {支持excel、mysql、sqlite等3种方式进行管理信息数据的存取。} |
034 | |
035 | screen.save to file {C:\snml2019\tmp\snml_1.png} from point {0} {0} to point {640} {480} |
036 | run.end |
037 | |
038 | macro.begin {draw_ladybird} |
039 | #var {x} value {0} |
040 | #var {y} value {0} |
041 | screen.set mode {stroke} |
042 | screen.set color red {0} green {0} blue {0} |
043 | #screen.rect from point {0} {0} to point {127} {127} |
044 | screen.set color red {255} green {0} blue {0} |
045 | screen.set mode {fill} |
046 | |
047 | var {x1} value number {~x~+60} |
048 | var {y1} value number {~y~+78} |
049 | screen.arc at point {~x1~} {~y1~} radius {50} from {0} to {360} |
050 | screen.set color red {0} green {0} blue {0} |
051 | |
052 | var {x1} value number {~x~+60} |
053 | var {y1} value number {~y~+33} |
054 | screen.arc at point {~x1~} {~y1~} radius {25} from {180} to {360} |
055 | |
056 | var {x1} value number {~x~+60} |
057 | var {y1} value number {~y~+28} |
058 | screen.set color red {0} green {0} blue {0} |
059 | screen.arc at point {~x1~} {~y1~} radius {100} from {85} to {95} |
060 | |
061 | var {x1} value number {~x~+60} |
062 | var {y1} value number {~y~+33} |
063 | var {x2} value number {~x~+80} |
064 | var {y2} value number {~y~+5} |
065 | |
066 | screen.line from point {~x1~} {~y1~} to point {~x2~} {~y2~} |
067 | var {x2} value number {~x~+40} |
068 | screen.line from point {~x1~} {~y1~} to point {~x2~} {~y2~} |
069 | |
070 | var {x1} value number {~x~+80} |
071 | var {y1} value number {~y~+5} |
072 | screen.arc at point {~x1~} {~y1~} radius {2} from {0} to {360} |
073 | var {x1} value number {~x~+40} |
074 | screen.arc at point {~x1~} {~y1~} radius {2} from {0} to {360} |
075 | |
076 | screen.set color red {255} green {255} blue {255} |
077 | |
078 | var {x1} value number {~x~+48} |
079 | var {y1} value number {~y~+20} |
080 | screen.arc at point {~x1~} {~y1~} radius {5} from {0} to {360} |
081 | var {x1} value number {~x~+72} |
082 | screen.arc at point {~x1~} {~y1~} radius {5} from {0} to {360} |
083 | |
084 | screen.set color red {0} green {0} blue {0} |
085 | |
086 | var {x1} value number {~x~+48} |
087 | var {y1} value number {~y~+19} |
088 | screen.arc at point {~x1~} {~y1~} radius {3} from {0} to {360} |
089 | |
090 | var {x1} value number {~x~+72} |
091 | screen.arc at point {~x1~} {~y1~} radius {3} from {0} to {360} |
092 | |
093 | var {x1} value number {~x~+60} |
094 | var {y1} value number {~y~+43} |
095 | screen.arc at point {~x1~} {~y1~} radius {10} from {0} to {360} |
096 | |
097 | var {x1} value number {~x~+90} |
098 | var {y1} value number {~y~+59} |
099 | screen.arc at point {~x1~} {~y1~} radius {8} from {0} to {360} |
100 | var {x1} value number {~x~+30} |
101 | screen.arc at point {~x1~} {~y1~} radius {8} from {0} to {360} |
102 | |
103 | var {x1} value number {~x~+75} |
104 | var {y1} value number {~y~+73} |
105 | screen.arc at point {~x1~} {~y1~} radius {8} from {0} to {360} |
106 | var {x1} value number {~x~+45} |
107 | screen.arc at point {~x1~} {~y1~} radius {8} from {0} to {360} |
108 | |
109 | var {x1} value number {~x~+90} |
110 | var {y1} value number {~y~+100} |
111 | screen.arc at point {~x1~} {~y1~} radius {8} from {0} to {360} |
112 | var {x1} value number {~x~+30} |
113 | screen.arc at point {~x1~} {~y1~} radius {8} from {0} to {360} |
114 | macro.end |
执行C:\snml2019\screen_nms1.bat,点击“Go”或“连续执行按钮”执行脚本,脚本执行结果如下:
| C:\snml2019\text\text_nms1.txt |
001 | |
002 | screen.set color red {0} green {0} blue {0} |
003 | screen.text at point {150} {30} string {16、text测试} |
004 | var {v_y} value {60} |
005 | screen.text at point {10} {~v_y~} string {序号} |
006 | screen.text at point {100} {~v_y~} string {以9x9乘法表为例,演示text相关功能} |
007 | screen.line from point {10} {75} to point {630} {75} |
008 | var {v_i} value {0} |
009 | var {v_x} value {0} |
010 | var {v_y} value {0} |
011 | var {x} value {0} |
012 | var {y} value {0} |
013 | var {v_xy} value {0} |
014 | |
015 | loop.begin |
016 | var {v_y} add number {1} |
017 | var {v_x} value {0} |
018 | var {y} value number {70+28*~v_y~} |
019 | screen.text at point {5} {~y~} string {第~v_y~行:} |
020 | #run.set loglevel {debug} |
021 | text.add {第~v_y~行: } |
022 | run.set loglevel {nolog} |
023 | loop.begin |
024 | var {v_x} add number {1} |
025 | var {v_time} value datetime |
026 | var {v_xy} value number {~v_x~*~v_y~} |
027 | var {v_xy} adjust length {3} align {left} |
028 | #run.set loglevel {debug} |
029 | text.add {~v_x~*~v_y~=~v_xy~ } |
030 | run.set loglevel {nolog} |
031 | var {x} value number {~v_x~*50} |
032 | |
033 | screen.text at point {~x~} {~y~} string {~v_x~*~v_y~=~v_xy~} |
034 | |
035 | if.var {v_x} >= {~v_y~} |
036 | #run.set loglevel {debug} |
037 | text.add {%0d%0a} |
038 | run.set loglevel {nolog} |
039 | loop.exit |
040 | if.end |
041 | loop.end |
042 | text.tailpointer move to tail |
043 | text.headpointer move forward after {第~v_y~行:} |
044 | |
045 | text.line get all words |
046 | #text.line get all words between {1} and {%0d} separated by { } |
047 | text.get var {word_no2} word number {2} |
048 | |
049 | if.var {v_y} >= {9} |
050 | loop.exit |
051 | if.end |
052 | loop.end |
053 | |
054 | text.headpointer move to head |
055 | text.tailpointer move to tail |
056 | text.save to file {C:\snml2019\tmp\text99.txt} |
057 | text.replace {*} with {x} |
058 | text.headpointer move to head |
059 | text.tailpointer move to tail |
060 | text.save to file {C:\snml2019\tmp\text99x.txt} |
061 | |
062 | text.replace {x} with {X} |
063 | text.headpointer move to head |
064 | text.tailpointer move to tail |
065 | text.save to file {C:\snml2019\tmp\text99X2.txt} |
066 | |
067 | text.replace {行:1X} with {.行. 1 * } |
068 | text.headpointer move to head |
069 | text.tailpointer move to tail |
070 | text.save to file {C:\snml2019\tmp\text99X3.txt} |
071 | |
072 | text.replace {X2} with {乘以2} |
073 | text.replace {X8} with {乘以8} |
074 | |
075 | text.headpointer move to head |
076 | text.tailpointer move to tail |
077 | text.save append to file {C:\snml2019\tmp\text99X3.txt} |
078 | |
079 | run.end |
| C:\snml2019\ping\ping_nms1.txt |
001 | screen.text at point {150} {30} string {9、ping测试:ttl、size、roundtrip_time、ip} |
002 | |
003 | var {v_ttl} value {0} |
004 | var {v_y} value {60} |
005 | screen.text at point {50} {~v_y~} string {发送ping请求参数} |
006 | screen.line from point {10} {75} to point {180} {75} |
007 | screen.text at point {350} {~v_y~} string {ping应答参数} |
008 | screen.line from point {200} {75} to point {630} {75} |
009 | |
010 | #run.set loglevel {debug} |
011 | var {v_y} value {80} |
012 | screen.text at point {10} {~v_y~} string {目的IP地址} |
013 | screen.text at point {110} {~v_y~} string {TTL} |
014 | screen.text at point {150} {~v_y~} string {字节数} |
015 | |
016 | screen.text at point {200} {~v_y~} string {IP地址} |
017 | screen.text at point {300} {~v_y~} string {TTL} |
018 | screen.text at point {350} {~v_y~} string {字节数} |
019 | screen.text at point {400} {~v_y~} string {毫秒数} |
020 | screen.text at point {450} {~v_y~} string {ping.status} |
021 | |
022 | #screen.line from point {10} {100} to point {630} {100} |
023 | |
024 | |
025 | #var {ip_addr} value {192.168.118.2} |
026 | run.set loglevel {debug} |
027 | dns.get var {ip_addr} host {mail.163.com} |
028 | |
029 | var {v_ttl} value {0} |
030 | var {v_y} value {80} |
031 | var {v_sendbytes} value {1000} |
032 | loop.begin |
033 | var {v_ttl} add number {1} |
034 | var {v_y} add number {20} |
035 | run.set loglevel {debug} |
036 | ping.ip {~ip_addr~} ttl {~v_ttl~} size {~v_sendbytes~} |
037 | run.set loglevel {nolog} |
038 | screen.text at point {10} {~v_y~} string {~ping.dest_ip~} |
039 | screen.text at point {110} {~v_y~} string {~v_ttl~} |
040 | screen.text at point {150} {~v_y~} string {~v_sendbytes~} |
041 | |
042 | screen.text at point {200} {~v_y~} string {~ping.reply_ip~} |
043 | screen.text at point {300} {~v_y~} string {~ping.reply_ttl~} |
044 | screen.text at point {350} {~v_y~} string {~ping.reply_bytes~} |
045 | screen.text at point {400} {~v_y~} string {~ping.roundtrip_time_milliseconds~} |
046 | screen.text at point {450} {~v_y~} string {~ping.status~} |
047 | if.var {v_ttl} > {16} |
048 | loop.exit |
049 | if.end |
050 | loop.end |
051 | |
052 | run.end |
| C:\snml2019\excel\excel_nms1.txt |
001 | screen.text at point {250} {30} string {11、excel 测试} |
002 | var {v_y} value {60} |
003 | screen.text at point {50} {~v_y~} string {写入C、D列} |
004 | screen.line from point {10} {75} to point {180} {75} |
005 | screen.text at point {220} {~v_y~} string {读取IP列} |
006 | screen.line from point {200} {75} to point {340} {75} |
007 | screen.text at point {350} {~v_y~} string {读取MAC列} |
008 | screen.line from point {350} {75} to point {630} {75} |
009 | excel.open {C:\snml2019\excel\snml.xlsx} sheet {Sheet1} |
010 | var {v_time} value datetime |
011 | var {v_i} value {1} |
012 | loop.begin |
013 | var {v_i} add number {1} |
014 | var {v_y} add number {18} |
015 | if.var {v_y} > {400} |
016 | loop.exit |
017 | if.end |
018 | var {v_time} value datetime |
019 | screen.text at point {10} {~v_y~} string {~v_i~} |
020 | screen.text at point {50} {~v_y~} string {~v_time~} |
021 | excel.cell {D~v_i~} value {[~v_time~]} |
022 | excel.get var {excel.B} cell {B~v_i~} |
023 | screen.text at point {200} {~v_y~} string {~excel.B~} |
024 | arp.get var {arp_ip_mac} ip {~excel.B~} |
025 | excel.cell {C~v_i~} value {~arp_ip_mac~} |
026 | excel.get var {excel.C} cell {C~v_i~} |
027 | screen.text at point {350} {~v_y~} string {~excel.C~} |
028 | |
029 | loop.end |
030 | excel.close |
031 | run.end |
| C:\snml2019\smtp\smtp_nms1.txt |
001 | screen.text at point {250} {30} string {12、smtp:发送邮件测试} |
002 | |
003 | var {v_time} value datetime |
004 | var {v_y} value {60} |
005 | |
006 | |
007 | screen.text at point {10} {~v_y~} string {sina邮箱发送邮件开始:~v_time~} |
008 | |
009 | smtp.server {smtp.sina.com} port {25} username {xxxaaaaabbb@sina.com} password {myPassword} |
010 | smtp.subject {发送邮件测试:~v_time~} body {邮件正文%0a,发送时间:~v_time~} |
011 | smtp.add attachment {C:\snml2019\excel\snml.xlsx} |
012 | smtp.add attachment {C:\snml2019\tmp\text99.txt} |
013 | run.set loglevel {debug} |
014 | smtp.send to {myEmail@163.com} |
015 | run.set loglevel {nolog} |
016 | screen.text at point {300} {~v_y~} string {发送邮件完成} |
017 | |
018 | |
019 | var {v_time} value datetime |
020 | var {v_y} add number {20} |
021 | |
022 | screen.text at point {10} {~v_y~} string {126邮箱发送邮件开始:~v_time~} |
023 | |
024 | smtp.server {smtp.126.com} port {25} username {xxxaaaaabbb@126.com} password {myPassword} |
025 | smtp.subject {发送邮件测试:~v_time~} body {邮件正文%0a,发送时间:~v_time~} |
026 | smtp.add attachment {C:\snml2019\excel\snml.xlsx} |
027 | smtp.add attachment {C:\snml2019\tmp\text99.txt} |
028 | run.set loglevel {debug} |
029 | smtp.send to {myEmail@163.com} |
030 | run.set loglevel {nolog} |
031 | screen.text at point {300} {~v_y~} string {发送邮件完成} |
032 | |
033 | |
034 | var {v_time} value datetime |
035 | var {v_y} add number {20} |
036 | screen.text at point {10} {~v_y~} string {163邮箱发送邮件开始:~v_time~} |
037 | |
038 | smtp.server {smtp.163.com} port {25} username {myEmail@163.com} password {myPassword} |
039 | smtp.subject {发送邮件测试:~v_time~} body {邮件正文%0a,发送时间:~v_time~} |
040 | smtp.add attachment {C:\snml2019\excel\snml.xlsx} |
041 | smtp.add attachment {C:\snml2019\tmp\text99.txt} |
042 | run.set loglevel {debug} |
043 | smtp.send to {xxxaaaaabbb@126.com} |
044 | run.set loglevel {nolog} |
045 | screen.text at point {300} {~v_y~} string {发送邮件完成} |
046 | |
047 | run.end |
| C:\snml2019\tcp\tcp_nms1.txt |
001 | screen.set color red {0} green {0} blue {0} |
002 | screen.text at point {150} {30} string {13.1、tcp.client测试} |
003 | var {v_y} value {60} |
004 | screen.text at point {10} {~v_y~} string {序号} |
005 | screen.text at point {250} {~v_y~} string {tcp.recv text.bytes} |
006 | screen.line from point {10} {75} to point {460} {75} |
007 | |
008 | var {v_time} value datetime |
009 | var {v_i} value {0} |
010 | |
011 | |
012 | loop.begin |
013 | |
014 | var {v_i} add number {1} |
015 | var {v_y} add number {18} |
016 | var {v_time} value datetime |
017 | |
018 | var {server_port} value number {50000+~v_i~} |
019 | screen.text at point {10} {~v_y~} string {~v_i~, ~v_time~:~server_port~} |
020 | run.nms {C:\snml2019\tcp\tcp_server1.nms ~server_port~} |
021 | tcp.connect ip {127.0.0.1} port {~server_port~} |
022 | tcp.send {tcp.client:~v_time~} |
023 | tcp.send {%0d%0a04} |
024 | tcp.send {client.end%0d%0a} |
025 | tcp.recv expect {server.end} |
026 | tcp.close |
027 | |
028 | screen.text at point {250} {~v_y~} string {~text.bytes~} |
029 | if.var {v_y} > {400} |
030 | loop.exit |
031 | if.end |
032 | |
033 | loop.end |
034 | |
035 | run.end |
| C:\snml2019\ssh\ssh_nms1.txt |
001 | screen.text at point {150} {30} string {15、ssh测试,(ssh需要发送邮件索取授权)} |
002 | var {v_y} value {60} |
003 | screen.text at point {10} {~v_y~} string {序号} |
004 | |
005 | screen.line from point {10} {75} to point {160} {75} |
006 | |
007 | screen.line from point {180} {75} to point {270} {75} |
008 | |
009 | screen.line from point {300} {75} to point {630} {75} |
010 | |
011 | screen.text at point {10} {400} string {ssh需要发送邮件索取授权,邮箱1:snml2019@protonmail.com} |
012 | screen.text at point {10} {425} string {ssh需要发送邮件索取授权,邮箱2:snml2019@hotmail.com} |
013 | |
014 | var {v_time} value datetime |
015 | var {v_i} value {0} |
016 | |
017 | loop.begin |
018 | |
019 | var {v_i} add number {1} |
020 | var {v_y} add number {18} |
021 | |
022 | ssh.connect ip {192.168.186.132} port {22} username {cisco} password {cisco} |
023 | ssh.set onrecv {-More-} send { %0a} |
024 | ssh.recv for {3} seconds |
025 | ssh.send {show version%0a} |
026 | ssh.recv expect {Version} |
027 | ssh.recv for {3} seconds |
028 | ssh.close |
029 | text.headpointer move to head |
030 | text.tailpointer move to tail |
031 | text.save append to file {C:\snml2019\ssh\ssh_out~v_i~.txt} |
032 | screen.text at point {10} {~v_y~} string {~v_i~} |
033 | screen.text at point {50} {~v_y~} string {ssh.recv:接收到~text.bytes~字节 } |
034 | text.delete from headpointer |
035 | |
036 | if.var {v_y} > {400} |
037 | loop.exit |
038 | if.end |
039 | loop.end |
040 | run.end |
| C:\snml2019\ssh\sshreg_nms.txt |
001 | screen.text at point {150} {30} string {15、ssh测试,(ssh需要发送邮件索取授权)} |
002 | var {v_y} value {60} |
003 | screen.text at point {10} {~v_y~} string {序号} |
004 | |
005 | screen.line from point {10} {75} to point {630} {75} |
006 | |
007 | screen.line from point {10} {425} to point {630} {425} |
008 | screen.text at point {10} {435} string {ssh需要发送邮件索取授权,执行ssh_req.bat,发送ssh_req.txt索取授权} |
009 | screen.text at point {10} {455} string {邮箱1:snml2019@protonmail.com,邮箱2:snml2019@hotmail.com} |
010 | |
011 | var {v_time} value datetime |
012 | var {v_i} value {0} |
013 | |
014 | text.add {run.version=[~run.version~]%0d%0a} |
015 | text.add {run.arg.1=[~run.arg.1~]%0d%0a} |
016 | text.add {v_time=[~v_time~]%0d%0a} |
017 | |
018 | text.add {os.type=[~os.type~]%0d%0a} |
019 | text.add {os.version=[~os.version~]%0d%0a} |
020 | |
021 | text.add {nic.ip=[~nic.ip~]%0d%0a} |
022 | text.add {nic.description=[~nic.description~]%0d%0a} |
023 | text.add {nic.mac=[~nic.mac~]%0d%0a} |
024 | |
025 | text.add {ssh需要发送邮件索取授权,执行ssh_req.bat,发送ssh_req.txt索取授权%0d%0a} |
026 | text.add {邮箱1:snml2019@protonmail.com,邮箱2:snml2019@hotmail.com%0d%0a} |
027 | |
028 | text.headpointer move to head |
029 | text.tailpointer move to tail |
030 | text.save append to file {C:\snml2019\ssh\ssh_req.txt} |
031 | screen.text at point {10} {80} string { 授权请求文件C:\snml2019\ssh\ssh_req.txt 已生成, ~text.bytes~字节 } |
032 | run.end |