#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$") ; } }; |
#2
|
|||
|
|||
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 |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|