Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting


Thread Tools Rate Thread Display Modes
Old 11-19-2018, 10:59 AM
Caster Caster is offline
Registered User
Join Date: Nov 2018
Posts: 1
Run Next Line in .txt file

I am trying to run a script for backups and in my text file is a list of hosts that backups need to occur on. The script runs just fine for the first host, but then stops and does not go to the next line in the .txt file. How do I remedy this?

Below is my script.

# $language = "JScript"
# $interface = "1.0"

// Open the file c:\temp\file.txt, read it line by line sending each
// line to the server. Note, to run this script successfully you may need
// to update your script engines to ensure that the filesystemobject runtime
// is available.

function main()
var fso, f, r;
var ForReading = 1, ForWriting = 2;

fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.OpenTextFile("c:\\Documents\\Backups\\Scripting_Backups.txt");

crt.Screen.Synchronous = true;

var str;
while ( true )

str = f.Readline();
str += "\015" ;
crt.Screen.Send( str );
crt.Screen.WaitForString ( "?", 10 ) ;
crt.Screen.Send ( "yes\015" ) ;
//crt.Screen.Sendkeys ( "~" ) ;
crt.Screen.WaitForString ( "password:" ) ;
crt.Screen.Send ( "xxxxxxxx\015" ) ;
//crt.Screen.Sendkeys ( "~" ) ;
//crt.Screen.WaitForString ("prompt$") ;
Reply With Quote
Old 11-19-2018, 11:22 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
Join Date: Jan 2017
Posts: 654
Hi Caster,

We do have an example script that may help save you some headache.

The script demonstrates how to connect to hosts read in from a "hosts" file and for each host, send a list of commands read in from a "commands" file.

Run Commands On Multiple Hosts And Log Results

While the example script is available in VBScript or Python we don't currently have a JScript version available. I thought I might see if the example script fits your needs before we got to far into troubleshooting the script you provided.

VanDyke Software
Technical Support
(505) 332-5730
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 02:36 AM.