Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > General

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-16-2014, 12:31 PM
jbd1300 jbd1300 is offline
Registered User
 
Join Date: Dec 2014
Posts: 18
Thumbs down For Each or Do Until----Help Please

I am building a script that can detect if a current modem is in use vs. what is open. However, I don't know what conditional loop to use?

I.E
I have a modem farm, and have currently in use.

router#sh users
Line User Host(s) Idle Location
tty 1/4 idle 00:00:06 modem5
tty 1/6 idle 00:02:13 modem5
tty vty 1 User modem5 00:00:10 IPaddr
tty vty 2 User modem7 00:02:14 IPaddr
*324 con User idle 00:00:00 IPaddr
tty con USer idle 00:01:23 IPaddr

Interface User Mode Idle Peer Address

router#

This is what i have so far. I get into an infinite loop with the following code. Anyone got a good idea of how I can pick a modem that's is open and not in use?

Sub Main()

' turn on synchronous mode
crt.Screen.Synchronous = True

crt.Screen.Send "show users" & chr(13)

Dim n
n=""

Dim modem_inuse(10)
modem_inuse(0) = "idle"
modem_inuse(1) = "modem1"
modem_inuse(2) = "modem2"
modem_inuse(3) = "modem3"
modem_inuse(4) = "modem5"
modem_inuse(5) = "modem6"
modem_inuse(6) = "modem7"
modem_inuse(7) = "modem8"
modem_inuse(8) = "modem15"
modem_inuse(9) = "modem16"

For Each modem in modem_inuse

Do Until n = "modem_found"

Dim Host_Inuse

Host_Inuse = crt.Screen.WaitForStrings(modem_inuse(0), 10)
'Tested this out as well, and doesn't work.
'Host_Inuse = crt.Screen.WaitForStrings("idle", "modem1", "modem2", "modem3" , "modem5", "modem6", "modem7", "modem8", "modem15", "modem16", 10)
Select Case Host_Inuse
Case 0
MsgBox "Timed out waiting for strings"
Exit Do
Case 1
MsgBox "Found idle string!"
Case 2
MsgBox "Found modem1 string!"

Case 3
MsgBox "Found modem2 string!"

Case 4
MsgBox "Found modem3 string!"

Case 5
MsgBox "Found modem5 string!"

Case 6
MsgBox "Found modem6 string!"

Case 7
MsgBox "Found modem7 string!"

Case 8
MsgBox "Found modem8 string!"

Case 9
MsgBox "Found modem15 string!"

Case 10
MsgBox "Found modem16 string!"

Case 11
MsgBox "All Modems are in use!"

End Select

'Exit Do

Loop

Next

End Sub
 

Tags
#auto-select , #conditionalloops


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 10:17 AM.