分类: 系统运维
2012-01-16 15:53:24
关于access表设计可参考代码设计则可。。
# $language = "VBScript"
# $interface = "1.0"
function echomore()
Do while (crt.Screen.WaitForString("--- More ---",1)<>False)
crt.Screen.Send chr(10)
Loop
End function
Cnstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=wgw_db.mdb;Persist Security Info=False"
tabname="wgw_config" '设备登录信息表
Set cn=CreateObject("ADODB.Connection")
Set rs=CreateObject("ADODB.Recordset")
'Dim fso, MyFile
'Set fso = CreateObject("Scripting.FileSystemObject")
'Set MyFile = fso.CreateTextFile("testfile.txt", True)
cn.Open Cnstr
rs.Open "select * from "+tabname,cn,1,3
'登录中转服务器
crt.Session.Connect ("/telnet 132.118.109.95")
crt.Screen.WaitForString "login:"
crt.screen.Send "gyhong" & Chr(10)
'crt.Screen.WaitForString "PASSCODE:"
'crt.screen.Send Chr(10)
crt.Screen.WaitForString "assword:"
crt.screen.Send "gyhong" & Chr(10)
While Not rs.eof
num=rs("num") '设备号,方便查看备份情况
check=rs("check") '设备是否需要备份
Dim result
if check="y" then
settype=rs("settype") '判断采用执行那个备份步骤进程备份操作
ipaddr=rs("ipaddr") '设备IP地址
login=rs("login") '登录用户名
passwd=rs("passwd") '密码一
su_passwd=rs("su_passwd") '密码二
prompt=rs("hostname")&rs("prompt") '互动识别符
hostname=rs("hostname")
filename=rs("ipaddr")&".log"
'开始执行操作
'交换机 —操作行式一
if settype="route_quidway" then
crt.screen.Send chr(10)
crt.Session.LogFileName = filename
crt.Session.Log True
crt.Screen.WaitForString ">"
'登录switch systme
crt.screen.Send "telnet "&ipaddr & Chr(10)
result = crt.screen.WaitForStrings("Username:", "Password:",10)
If result = 1 Then
'crt.Screen.WaitForString "name:"
crt.screen.Send login & Chr(10)
crt.Screen.WaitForString "assword:"
crt.screen.Send passwd & Chr(10)
End If
If result = 2 Then
'crt.Screen.WaitForString "name:"
crt.screen.Send passwd & Chr(10)
End If
If result = 0 Then
MsgBox "Timed out!"
End If
crt.screen.WaitForString prompt
crt.screen.Send "super" & Chr(10)
crt.Screen.WaitForString "assword:"
crt.screen.Send su_passwd & Chr(10)
crt.screen.WaitForString prompt
crt.screen.Send "disp version" & Chr(10)
echomore()
crt.screen.Send chr(10)
crt.screen.WaitForString prompt
crt.screen.Send "quit" & Chr(10)
crt.sleep 100
crt.Session.Log False
end if
end if
rs.movenext
Wend
'退出OSS系统
crt.Screen.WaitForString ">"
crt.screen.Send "exit"&Chr(10)