View Single Post
Old 05-01-2013, 03:19 PM
miked's Avatar
miked miked is offline
Registered User
Join Date: Feb 2004
Posts: 2,039
Thanks. There are multiple problems:
  • SecureCRT does not currently support /SCRIPT on a per session basis.
  • Using crt.screen.Send sends to the active tab, so it's not tab safe.
  • Using crt.Screen.Send and crt.screen.Send back to back, without WaitForString in between, inevitably leads to problems.
An immediately available alternative would be to split up the wsh call to start SecureCRT sessions without /T. "C:\CRT\SecureCRT.exe /s Payroll /SCRIPT C:\brickman\crt_scripts\PayrollScripts\Branch671.vbs "C:\CRT\SecureCRT.exe /s Payroll /SCRIPT C:\brickman\crt_scripts\PayrollScripts\Branch673.vbs "C:\CRT\SecureCRT.exe /s Payroll /SCRIPT C:\brickman\crt_scripts\PayrollScripts\Branch674.vbs
Since /SCRIPT cannot be called multiple times, you need to find another way to activate the script.

A simple way might be:
  • Make a single, tab safe script named BranchScript.vbs
  • Have BranchScript.vbs read an argument that's sent to it, and based on that argument, send a specific line. Now you don't need to maintain so many scripts - you just need one script.
  • Instead of starting SecureCRT with a specific script, like this: "SecureCRT.exe /s Payroll /SCRIPT Branch674.vbs

    do something more general and pass in an argument, like this (pseudocode):
    foreach nBranchNum in ("674, 681, 781, 791, etc...") "SecureCRT.exe /SCRIPT "BranchScript.vbs" /ARG nBranchNum /T /S Payroll

Tab safety: you'll probably want to use GetScriptTab, which returns the tab or tiled session window from which the script was started.[/QUOTE] This function will be useful because each script will know which session started it. This will help you keep track of which tab to send to or read from.

I recognize that this is just an overview, and there isn't a quick solution. Fixing the back to back Sends, and making it script safe, the script will have little in common with what it is now when you're finished. It might be easier to start over with a script like: Read Data From Separate Hosts/Commands File And Log To Individual Files .
VanDyke Software
Technical Support
Reply With Quote