Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting


Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 08-09-2014, 06:45 PM
bigkid123 bigkid123 is offline
Registered User
Join Date: Sep 2012
Posts: 2
Script to run in Tabs


I am fairly new to writing scripts and very limited to the knowledge needed to even know where to start. I have modified this one but not quite sure of how to get it to execute in tabs that are already connected to my servers. I am basically saving the screen data to a file but would like all of the sessions to log to the same file. I believe the script that I have below would accomplish this but not sure of the code to use to have it run per open tab. Any help would be appreciated.

I also have an issue of when it writes the SessionName into the .txt file it includes the folders with the Session name and not sure how to only show the Session name.

I have found this script to do a single / but not sure how to change it to multiple folders.

strSession = crt.Session.Path
If Instr(strSession, "\") Then
vSession = Split(strSession, "\")
strSession = vSession(1)
MsgBox strSession
MsgBox strSession
End If

I also found the following code which I believe would accomplish the send commands to multiple tabs but not quite sure how to update the script below to combine everything that I am needing.

Any help/guidance would be appreciated.

# $language = "VBScript"
# $interface = "1.0"

' Example script showing how to send commands to multiple tabs

Option Explicit

Sub Main()

Dim tab, index, nTabCount

nTabCount = crt.GetTabCount()

for index = 1 to nTabCount
set tab = crt.GetTab(index)
tab.screen.send "ping" & vbcr

End Sub

The script below is what I use to pull the needed data from the screen.

# $language = "VBScript"
# $interface = "1.0"

' This script demonstrates how to capture line by line output
' from a command sent to a server. It then saves each line of output
' to a file. This script shows how the 'WaitForStrings' command can be
' use to wait for multiple possible outputs.

' Constants used by OpenTextFile()
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Sub Main

crt.Screen.Synchronous = True

' Create an instance of the scripting filesystem runtime so we can
' manipulate files.
Dim fso, file
Dim strSessionName
Set fso = CreateObject("Scripting.FileSystemObject")

' Open a file for writing. The last True parameter causes the file
' to be created if it doesn't exist.
Set file = fso.OpenTextFile("c:\scrt.config\%S.txt", ForAppending, True)

' Stuff the data from the SecureCRT screen into a variable
' Using crt.Screen.Get2 instead of crt.Screen.Get allows us to capture
' \r and \n so that data appears in the file the same way it appears in
' the SecureCRT window.
szScreenData = crt.Screen.Get2(1, 1, crt.screen.Rows, crt.Screen.Columns)

'msgbox szScreenData

' Write the line out with an appended '\r\n'

' Extract data displayed on row 2, between columns 1 and 2
nProcesses = crt.Screen.Get(7,1,7,41)

' Extract data displayed on row 5, between columns 36 and 41
nFreeMem = crt.Screen.Get(5,36,5,41)

strSessionName = crt.Session.Path

file.Write strSessionName & vbCrLf
file.Write nProcesses & vbCrLf
' file.Write “Free Memory: “ & nFreeMem & VbCrLf
' file.Write szScreenData & vbCrLf

crt.screen.synchronous = false

End Sub
Reply With Quote

run , script , sessionname , tabs

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 01:34 AM.