View Single Post
  #1  
Old 11-19-2018, 11: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.Dialog.Prompt(str);
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