View Single Post
  #1  
Old 09-29-2015, 02:07 PM
benitocamela benitocamela is offline
Registered User
 
Join Date: Sep 2015
Posts: 5
loop in vbs script

I'm trying to make a loop to check the machine status after throwing some commands, ex:


# $language = "VBScript"
# $interface = "1.0"

Const ForReading = 1
Const ForWriting = 2

Sub Main

'Dim logfile
'logfile = "C:\TEMP\mysession.log"
'crt.Session.LogFileName = logfile
Dim fso, file, str
Set fso = CreateObject("Scripting.FileSystemObject")
'crt.Session.Log true
' Note: A runtime exception will be generated if 'input.txt' doesn't exist.
'
Set file = fso.OpenTextFile("C:file.txt", ForReading, False)
crt.Screen.Synchronous = True
crt.Screen.Clear

Do while file.AtEndOfStream <> True

str = file.Readline
' Send the line with an appended CR
crt.Screen.Send str & Chr(13)



crt.Screen.WaitForString "assword:",2
' Send your password followed by a carriage return
crt.Screen.Send "password" & VbCr

crt.Screen.WaitForString "@"
crt.Screen.Send "command-1" & VbCr
crt.Screen.WaitForString "@"

crt.Screen.Send "command-2" & VbCr
crt.Screen.WaitForString "@"

After that, i need to launch a command to check the router status.

If the result of this is OK, continuos the script, with a write command for example.

If the result is not OK, the command to check must be launched with a one minute interval until the router is ok,

Do not know how this loop, in the first loop.

Can you help me.

Thanks
Reply With Quote