VanDyke Software Forums

VanDyke Software Forums (
-   Scripting (
-   -   Loop on While Not {name}.atEndOfStream connection list. (

dsautter 10-11-2020 09:20 AM

Loop on While Not {name}.atEndOfStream connection list.
I would like to create a VBS script what would connect to multiple hosts and collect data. Pause a specified amount of time and then reconnect to each device and collect the data again.

1. do while x
2. Connect to each device
3. Collect output from show commands
4. End
5. Pause a prefined time
6. loop x

Please see the attached script for more details. Currently I have two duplicate sections with a different "While Not {}.atEndOfStream". Instead I would like to loop back to the top.

bgagnon 10-12-2020 08:12 AM

Hi dsautter,

There was nothing attached.

What version of SecureCRT are you using?

On what platform?

If Windows and if you are making your connections within the script, this would seem like the sort of task where you might use a SecureCRT command-line:

SecureCRT /Script "Path_to_my_script"
And maybe run it as a scheduled task at the desired interval.

If you do post the script, please elaborate on what undesired behavior you are seeing.

dsautter 10-12-2020 09:14 AM

Script attached
1 Attachment(s)
Hello Brenda,

The version is 8.7.1 on Windows 2008 R2 server.

Currently the only way to accomplish what I'm trying is to have multiple sections where it would be great to have the one section and just loop through it.


bgagnon 10-12-2020 10:57 AM

Hi Don,

I'm trying to understand the relevance of the source files. What is the reason for separate files? Why wouldn't you just have one file for reading in all the devices?

dsautter 10-12-2020 12:44 PM

Hello Brenda,

Let me see if I can explain what I'm trying to accomplish.

We want to run a test over a 48 period. Within the 48 hours, we want to connect to all the devices in the list, grab outputs from show commands, and then pause for 4 hours. After the 4 hours, connect to all the devices again, run the same commands, and repeat 11 more times.

Time 0
While Not DeviceIP2.atEndOfStream "Connect to each device"
collect outputs
end if
sleep for 4 hours
loop to top

I'm struggling with the outer loop, pause four hours, then go back to the "While Not DeviceIP2.atEndOfStream" to start the process of connecting to all devices and running the show commands.

bgagnon 10-12-2020 02:17 PM

Hi Don,

I still don't understand the need for multiple DeviceIP# files. :)

Since the time iterator is known and VBScript functions can determine exact number of hosts in the file, I would just do this with two For/Next loops:


read source file
split ip's into array
for x = 0 to 11
    for y = 0 to ubound(hosts)
        run cmds
        log output
    sleep 4 hrs

dsautter 10-13-2020 07:21 AM

1 Attachment(s)
Hello Brenda,

I removed the second section and uploaded the script with comments to try and simplify the ask.

Hope this helps.


bgagnon 10-14-2020 01:12 PM

Hi Don,

I posted what I felt was a reasonable alternative. I don't know how to accomplish it in the way you apparently want to accomplish it. :)

So we will just have to leave this open for community input.

All times are GMT -6. The time now is 07:16 PM.