Well, it doesn't look like you got any takers, so I guess I throw my hat in here. Why no third party programs? There are free third party programs/libraries that could make things easier. Such as TeraTermPro which has a built in script language that can easily do this. And there's a sourceforge library called TelScript, which might be useful (although I haven't tried it). Anyway, assuming that MSWinsock isn't off limits, since it is MS, here's something that might work. I thinks I covered everything in your pseudo script. Let me know...
==================
ShunUnshunFW.vbs
==================
dim firewall_ip, src_addr
Set objArgs = WScript.Arguments
'Make sure we are passed arguments
If objArgs.Count<>2 then Usage
firewall_ip = objArgs(0)
src_addr = objArgs(1)
Set oWinsock = CreateObject("MSWinsock.Wi
oWinsock.Protocol = 0 'sckTCPProtocol
oWinsock.Connect firewall_ip, 23
Do While oWinsock.State <> 7 'sckConnected
WScript.Sleep 100
If oWinsock.State = 9 Then 'sckError
MsgBox "Error connecting to Firewall at " & firewall_ip
WScript.Quit
End If
Loop
'Login, enable, and enter config mode
LoginEnableConfig
'send shun command
oWinsock.SendData "shun " & src_addr & vbCr
WScript.Sleep 100
'exit config and router
oWinsock.SendData "exit" & vbCr
WScript.Sleep 100
oWinsock.SendData "exit" & vbCr
WScript.Sleep 100
oWinsock.Close
wscript.sleep 1800000
'Re-connect
oWinsock.Connect firewall_ip, 23
'Login, enable, and enter config mode
LoginEnableConfig
'send unshun command
oWinsock.SendData "unshun " & src_addr & vbCr
WScript.Sleep 100
'exit config and router
oWinsock.SendData "exit" & vbCr
WScript.Sleep 100
oWinsock.SendData "exit" & vbCr
WScript.Sleep 100
oWinsock.Close
MsgBox "Script Complete."
WScript.Quit
Sub LoginEnableConfig()
Dim password1, enablepwd, sRouterName
sRouterName = "firewall"
password1 = "password1"
enablepwd = "enablepwd"
'Wait for Login prompt
If Not WaitForString("assword: ", 10) Then
MsgBox "Timeout while waiting for login prompt."
WScript.Quit
End If
'Send login password
oWinsock.SendData password1 & vbCr
WScript.Sleep 100
'Wait for login confirmation
If Not WaitForString(sRouterName & ">", 10) Then
MsgBox "Timeout while waiting for login confirmation."
WScript.Quit
End If
'Send enable command
oWinsock.SendData "en" & vbCr
WScript.Sleep 100
'Wait for enable confirmation
If Not WaitForString("assword: ", 10) Then
MsgBox "Timeout while waiting for enable command confirmation."
WScript.Quit
End If
'Send enable password
oWinsock.SendData enablepwd & vbCr
WScript.Sleep 100
'Wait for enable password confirmation
If Not WaitForString(sRouterName & "#", 10) Then
MsgBox "Timeout while waiting for enable password confirmation."
WScript.Quit
End If
'Send config command
oWinsock.SendData "config t" & vbCr
WScript.Sleep 100
'Wait for enable password confirmation
If Not WaitForString("(config)#",
MsgBox "Timeout while waiting for config command confirmation."
WScript.Quit
End If
End Sub
Function WaitForString(sFind, iTimeoutSeconds )
Dim StartTime, sTemp
Dim sInput
StartTime = Now
Do Until InStr(1, sInput, sFind)
WScript.Sleep 100
oWinsock.GetData sTemp, vbString
sInput = sInput & sTemp
If DateAdd("s", iTimeoutSeconds, StartTime) <= Now() Then
WaitForString = False
Exit Function
End If
Loop
WaitForString = True
End Function
Sub Usage()
MsgBox "This script needs to be called as follows:" & vbCrLf & "cscript ShunUnshunFW.vbs firewall_ip src_addr"
WScript.Quit
End Sub
Main Topics
Browse All Topics





by: brian_appliedcpuPosted on 2004-05-21 at 18:22:56ID: 11131316
Amendment.....
The best soltion would not use any third party programs like CRT.exe , just what is available in windows or JRE.