Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2  
Old 11-19-2018, 12:22 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 566
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.
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 05:08 PM.