MSCBSC 移動(dòng)通信論壇
搜索
登錄注冊(cè)
網(wǎng)絡(luò)優(yōu)化工程師招聘專(zhuān)欄 4G/LTE通信工程師最新職位列表 通信實(shí)習(xí)生/應(yīng)屆生招聘職位

【C友貼圖區(qū)】

C友貼圖和看圖,請(qǐng)到此版
勿發(fā)違規(guī)圖片

【C友開(kāi)心吧】

C友交流開(kāi)心笑話的區(qū)域
樂(lè)一樂(lè),就在開(kāi)心吧

【心情咖啡屋】

分享你的心情和通信生活
C友交流心情的地方

【求職招聘區(qū)】

招聘,求職,職業(yè)交流
討論通信人的職場(chǎng)前景



  • 閱讀:21496
  • 回復(fù):2
[原創(chuàng)] SecureCRT是個(gè)好東西,巧用SecureCRT vbs腳本批量對(duì)華為5620E進(jìn)行數(shù)據(jù)配制
木林森
中級(jí)會(huì)員



 發(fā)短消息    關(guān)注Ta 

積分 909
帖子 179
威望 8574 個(gè)
禮品券 0 個(gè)
專(zhuān)家指數(shù) 14
注冊(cè) 2010-6-19
專(zhuān)業(yè)方向  TD-SCDMA
回答問(wèn)題數(shù) 0
回答被采納數(shù) 0
回答采納率 0%
 
發(fā)表于 2011-11-01 00:25:24  只看樓主 
由于工作的需要,經(jīng)常要手工登錄到5620E進(jìn)行數(shù)據(jù)的配制,總覺(jué)得來(lái)來(lái)回都是那幾條命令,就想想能不能寫(xiě)些腳本讓其自動(dòng)運(yùn)行,這樣省時(shí)又省力。想到不如做到,立即上網(wǎng)查查相關(guān)資料,最后決定利用SecureCRT可執(zhí)行VBS腳本的這個(gè)特點(diǎn)來(lái)實(shí)現(xiàn)我想要的功能。
程序的大概思路是,寫(xiě)一個(gè)AddOnu.vbs的腳本文件,使其能從OnuIp.txt配制文件中循環(huán)的讀取Onu的IP地址及相關(guān)配制信息,程序根據(jù)這些信息可實(shí)現(xiàn)批量的對(duì)Oun進(jìn)行自動(dòng)登錄、寫(xiě)數(shù)據(jù)、保存、退出等一條龍服務(wù)。在OnuIp.txt中設(shè)置好你所要配制的Onu信息后,你只要在SecureCRT-腳本-運(yùn)行 中選擇執(zhí)行該腳本,即可端上一杯茶慢慢品味,5620E的數(shù)據(jù)配制不再讓你擔(dān)憂,程序一步到位幫你搞定。但一個(gè)重要的前提是這些Onu都是在線可連接的而且登錄密碼也都是一樣的,如其中有一臺(tái)不能正常連接或無(wú)法登錄,程序?qū)o(wú)法繼續(xù)運(yùn)行下去。
以下是各個(gè)文件的具休內(nèi)容:
--------------------AddOnu.vbs--------------------
# $language = "VBScript"
# $interface = "1.0"
Const ForReading = 1
Sub Main
On error resume Next
Dim OnuIp,MgIp,StartVlan,EndVlan,OnuNum,IPFileName,ErronNO
'斷開(kāi)主機(jī)連接
crt.session.Disconnect


'MsgBox(IPFileName)

'Set objFolder = objFSO.GetFolder(Server.MapPath("/"))
IPFileName="ONUIP.txt"
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
if not (fso.fileexists(IPFileName)) Then
nResult = MsgBox("在當(dāng)前目錄中找不到名稱(chēng)為""" & _
IPFileName & _
""" 的配制文件," & vbcrlf & vbcrlf & _
vbtab & "手工指定文件目錄請(qǐng)按<是>" & vbcrlf & vbcrlf & _
vbtab & "退出請(qǐng)按<否>" & vbcrlf & vbcrlf , vbYesNo)
If nResult=vbYes Then
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "Text Files|*.txt"
objDialog.FilterIndex = 2
objDialog.InitialDir = g_shell.SpecialFolders("MyDocuments")
nResult = objDialog.ShowOpen

If nResult <> 0 Then
IPFileName = objDialog.FileName
End If
Else
MsgBox("exit")
Exit Sub
End If
End If

Set f = fso.OpenTextFile(IPFileName, ForReading, 0)
Dim LineStr,params
Do While f.AtEndOfStream <> True
' Read each line of the printers file. '
'f.skipline跳過(guò)一行
' ErronNom=0
LineStr = f.Readline
If Trim(LineStr)<>"" andLeft(LineStr,2)<>"//" and Instr(LineStr, "|") > 0Then
'MsgBox LineStr

params = Split( LineStr,"|" )
OnuIp= params(0)
MgIp= params(1)
MgWgIp = params(2)
StartVlan = params(3)
EndVlan= params(4)
If StartVlan>EndVlan Then
MsgBox("起始Vlan不能大于結(jié)束Vlan,程序已退出!")
Exit Sub
End If
OnuNum = params(5)

'MsgBox(params(0)&params(1)&params(2)&params(3)&params(4)&params(5))

crt.Screen.Synchronous = True
crt.session.Connect("/telnet "& OnuIp )
'If crt.session.Connect("/telnet "& OnuIp )= False Then
'crt.Screen.WaitForString ("User name:", 1)
'MsgBox "Failed to connect to " & OnuIp
'ErronNom = 1
'End If


crt.screen.WaitForString "User name:",10
crt.screen.send "root" &vbCR
crt.screen.WaitForString "User password:",10
crt.screen.send "****" &vbCR

crt.screen.WaitForString "[n]:",2
crt.screen.send "y" &vbCR

crt.screen.WaitForString ">",10
crt.screen.send "enable" &vbCR

crt.screen.WaitForString "#",2
crt.screen.send "config" &vbCR

crt.screen.WaitForString "#",2
crt.screen.send "switch language-mode" &vbCR

Dim Str2
Str2=Split(MgIp,".")


crt.screen.WaitForString "#",2
crt.Screen.Send "tid-template add 33 format %05u parameter-list g+58900 name zte " &vbCR
crt.Screen.Send "tid-template add 34 format %05u parameter-list r name TD "&vbCR&vbCR
crt.Screen.Send "vlan 3000" &vbCR &vbCR
crt.Screen.Send "port vlan 3000 0/0 1" &vbCR
crt.Screen.Send "vlan "& StartVlan &" to "& EndVlan &"" &vbCR
crt.Screen.Send "y" &vbCR
crt.Screen.Send "port vlan"& StartVlan &" to "& EndVlan & "0/0 1" &vbCR
crt.Screen.Send "y" &vbCR
crt.Screen.Send "undo service-port all" &vbCR
crt.Screen.Send "y" &vbCR
crt.Sleep 1000
Dim i,j
j=0
For i= StartVlan to EndVlan
crt.Screen.Send " service-port "& j &"vlan "& i &" eth 0/1/"& j+1 &"user-vlan untaggedrx-cttr 1 tx-cttr 1" &vbCR
crt.Sleep 1000
j=j+1
Next

crt.Screen.Send Chr(13)
crt.Screen.Send "interface vlanif 3000 " &vbCR
crt.Screen.Send " ip address "& MgIp &" "& MgWgIp &vbCR
crt.Screen.Send " quit" &vbCR
crt.Screen.Send " voip" &vbCR
crt.Screen.Send " ip address media "& MgIp &""& Str2(0)&"."& Str2(1)&"."&Str2(2)&"."&"1 " &vbCR
crt.Screen.Send " ip address signaling "& MgIp &" " &vbCR
crt.Screen.Send " quit" &vbCR
crt.Screen.Send "interface h248 "& OnuNum &"" &vbCR
crt.Screen.Send "y" &vbCR
crt.Screen.Send "if-h248 attribute mgip "& MgIp &"mgport 2944 transfer udp" &vbCR &vbCR
crt.Screen.Send "if-h248 attribute mgcip_1 10.53.4.22mgcport_1 2944" &vbCR &vbCR
crt.Screen.Send "if-h248 attribute mg-media-ip "& MgIp &"" &vbCR &vbCR
crt.Screen.Send "if-h248 attribute profile-index 1 start-negotiate-version 2" &vbCR &vbCR
crt.Screen.Send "tid-format rtp prefix RTP/ template 34 pstn prefix AG template 33" &vbCR
crt.Screen.Send "mg-ringmode add 0 10 26 " &vbCR
crt.Screen.Send "if-h248 attribute profile-index 5" &vbCR &vbCR
crt.Screen.Send " quit" &vbCR
crt.Screen.Send " esl user " &vbCR
Dim m
For m=1 to 16
crt.Screen.Send "mgpstnuser add 0/2/"& m &"0 terminalid "&m &"telno 0000000" &vbCR &vbCR
crt.Sleep 1000
Next
crt.Screen.Send Chr(13)
crt.Screen.Send " quit" &vbCR
crt.Screen.Send "ip route-static 10.53.4.0 255.255.255.0 10.51."& Str2(2) &".1" &vbCR
crt.Screen.Send "ip route-static 10.51.0.0 255.255.0.0 10.51."& Str2(2) &".1 " &vbCR
crt.Screen.Send "snmp-agent trap source vlanif 100" &vbCR
crt.Screen.Send "save" &vbCR &vbCR

crt.screen.WaitForString "保存完成",2000
crt.screen.WaitForString "(config)#",5
crt.screen.send "quit" &vbCR


crt.screen.WaitForString "#",10
crt.screen.send "quit" &vbCR
crt.screen.send "y" &vbCR

crt.screen.WaitForString "請(qǐng)重建連接后登錄",1000
crt.Sleep 2000
crt.Screen.Synchronous = False
End If
Loop

End Sub


--------------------OnuIp.txt--------------------

// ONU管理IP |ONU語(yǔ)音IP |語(yǔ)音IP網(wǎng)關(guān)地址 | 起始VLan | 結(jié)束VLan | ONU編號(hào)
192.168.1.23|192.168.2.33|255.255.255.0|349|364|3
192.168.1.24|192.168.2.33|255.255.255.0|365|380|4

腳本代碼: 巧用SecureCRT vbs腳本批量對(duì)華為5620E進(jìn)行數(shù)據(jù)配制.rar (2.58 KB)

遺留問(wèn)題:
此腳本無(wú)法判斷oun是否接成功,如有哪位朋友能實(shí)現(xiàn)這個(gè)功能或?qū)υ撃_本進(jìn)行友好的完善,歡迎共同討論分享,QQ:16845612!
掃碼關(guān)注5G通信官方公眾號(hào),免費(fèi)領(lǐng)取以下5G精品資料
  • 1、回復(fù)“YD5GAI”免費(fèi)領(lǐng)取《中國(guó)移動(dòng):5G網(wǎng)絡(luò)AI應(yīng)用典型場(chǎng)景技術(shù)解決方案白皮書(shū)
  • 2、回復(fù)“5G6G”免費(fèi)領(lǐng)取《5G_6G毫米波測(cè)試技術(shù)白皮書(shū)-2022_03-21
  • 3、回復(fù)“YD6G”免費(fèi)領(lǐng)取《中國(guó)移動(dòng):6G至簡(jiǎn)無(wú)線接入網(wǎng)白皮書(shū)
  • 4、回復(fù)“LTBPS”免費(fèi)領(lǐng)取《《中國(guó)聯(lián)通5G終端白皮書(shū)》
  • 5、回復(fù)“ZGDX”免費(fèi)領(lǐng)取《中國(guó)電信5G NTN技術(shù)白皮書(shū)
  • 6、回復(fù)“TXSB”免費(fèi)領(lǐng)取《通信設(shè)備安裝工程施工工藝圖解
  • 7、回復(fù)“YDSL”免費(fèi)領(lǐng)取《中國(guó)移動(dòng)算力并網(wǎng)白皮書(shū)
  • 8、回復(fù)“5GX3”免費(fèi)領(lǐng)取《 R16 23501-g60 5G的系統(tǒng)架構(gòu)1
  • 對(duì)本帖內(nèi)容的看法? 我要點(diǎn)評(píng)





    優(yōu)化人生,成就夢(mèng)想!
     
    [充值威望,立即自動(dòng)到帳] [VIP貴賓權(quán)限+威望套餐] 另有大量?jī)?yōu)惠贈(zèng)送活動(dòng),請(qǐng)光臨充值中心
    充值擁有大量的威望和最高的下載權(quán)限,下載站內(nèi)資料無(wú)憂
    akxylx
    高級(jí)會(huì)員
    鎵嬫満鍙風(fēng)爜宸查獙璇? style=


     發(fā)短消息    關(guān)注Ta 

    紀(jì)念勛章·七周年   財(cái)富勛章·財(cái)運(yùn)連連   活動(dòng)·攝影達(dá)人  
    積分 1936
    帖子 391
    威望 350 個(gè)
    禮品券 140 個(gè)
    專(zhuān)家指數(shù) -59
    注冊(cè) 2011-10-13
    專(zhuān)業(yè)方向  GSM
    回答問(wèn)題數(shù) 0
    回答被采納數(shù) 0
    回答采納率 0%
     
    發(fā)表于 2011-11-01 00:55:22 
    技術(shù)問(wèn)題,回答得專(zhuān)家指數(shù),快速升級(jí)
    好東西 收下了 感謝分享

    對(duì)本帖內(nèi)容的看法? 我要點(diǎn)評(píng)

     
    [立即成為VIP會(huì)員,百萬(wàn)通信專(zhuān)業(yè)資料立即下載,支付寶、微信付款,簡(jiǎn)單、快速!]
    sunni98
    高級(jí)會(huì)員
    鎵嬫満鍙風(fēng)爜宸查獙璇? style=


     發(fā)短消息    關(guān)注Ta 

    積分 1534
    帖子 325
    威望 104846 個(gè)
    禮品券 5 個(gè)
    專(zhuān)家指數(shù) -141
    注冊(cè) 2008-4-13
    專(zhuān)業(yè)方向  通信工程
    回答問(wèn)題數(shù) 0
    回答被采納數(shù) 0
    回答采納率 0%
     
    發(fā)表于 2012-11-19 21:01:37 
    謝謝樓主 感謝分享

    對(duì)本帖內(nèi)容的看法? 我要點(diǎn)評(píng)

     
    最新通信職位:廣東通信人才網(wǎng) | 北京通信人才網(wǎng) | 上海通信人才網(wǎng) | 南京通信人才網(wǎng) | 西安通信人才網(wǎng) | 重慶通信人才網(wǎng) | 中國(guó)通信人才網(wǎng)

    快速回復(fù)主題    
    標(biāo)題 [原創(chuàng)] SecureCRT是個(gè)好東西,巧用SecureCRT vbs腳本批量對(duì)華為5620E進(jìn)行數(shù)據(jù)配制" tabindex="1">
    內(nèi)容
     上傳資料請(qǐng)點(diǎn)左側(cè)【添加附件】

    當(dāng)前時(shí)區(qū) GMT+8, 現(xiàn)在時(shí)間是 2025-02-03 00:17:59
    渝ICP備11001752號(hào)  Copyright @ 2006-2016 mscbsc.com  本站統(tǒng)一服務(wù)郵箱:mscbsc@163.com

    Processed in 0.408365 second(s), 16 queries , Gzip enabled
    TOP
    清除 Cookies - 聯(lián)系我們 - 移動(dòng)通信網(wǎng) - 移動(dòng)通信論壇 - 通信招聘網(wǎng) - Archiver