Solved

VBS Script Manipulation and SecureCRT

Posted on 2012-03-13
4
1,619 Views
Last Modified: 2012-03-30
Hello Experts,

This quest will need an expert proficient in VBS script and an application called SecureCRT.

Is it possible to have script that activate logging in all the separate tabs and log the out to a particular folder.

For example, in screenshot you can see there are five tabs with five different sessions. You can also see a folder in the 'Connect in Tab' dialogue box called GLBP Lab 58.

I would like help compiling a script that will activate the log session for each of the tabs and select the appropriate folder from where the session originated - in this case GLBP Lab 58


Just so as to start the ball rolling the following is a script that will log a single session, at a specified folder. Hopefully, an expert will be able to use this as baseline.
# $language = "VBScript"
# $interface = "1.0"

' This script sets a specific logfile, enables logging then connects
' to a server. After capturing the output of a command to the logfile
' logging is disabled and it disconnects.

Sub Main

  ' Set the name of the log file name "YYMMDD.log"
  '
  Dim logfile
  logfile = "C:\TEMP\mysession.log"
  crt.Session.LogFileName = logfile

  ' Enable logging
  '
  crt.Session.Log True

  ' Send a unix command. The output of the command will
  ' be captured to the logfile.
  '
  crt.Screen.Send "date" & vbCr

  ' Wait again for my login prompt or 5 seconds
  '
  crt.Screen.WaitForString "linux$", 5

  ' Turn off synchronous mode
  crt.Screen.Synchronous = false

  ' Stop logging and disconnect.
  '
  crt.Session.Log False
  crt.Session.Disconnect

End Sub

Open in new window


Cheers

Carlton
seccure2.jpg
0
Comment
Question by:cpatte7372
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:khairil
ID: 37714119
Hi,

I afraid my answer will not satisfy you. After went thru SecureCRT docs on scripting. I do not think that can be done. If you read all the property and method exposed by CRT object, there is nothing about folder it contains from. Thus the session will not know from what container (folder) it starts.

However, you still have a work around here. You can use the title of the Windows/Tab, what you need to do is to set each connection with additional windows propety, this can be done on connection properties->Appearance->Windows->Title Bar. You can grap this tab title propeties and use as variable for output folder.

 You then need to switch on next tab index to make it active so that the title will change to  new tab index title.

Just my 2 cent.
0
 

Author Comment

by:cpatte7372
ID: 37715463
khairil,

Thanks for taking time to research this issue on my behalf.

You're workout seems like my only option. Would you happen to know how I would go about grabbing the title properties and use it as a variable for the output folder?

Cheers
0
 
LVL 13

Accepted Solution

by:
khairil earned 500 total points
ID: 37718207
Hi,

You can get information on tab caption/title using tab object:

g_szTabCaption = objCurrentTab.Caption

Open in new window


You can go thru snippet as below to get information of session and caption. This is portion of code is modified from the sampel file in SecureCRT script folder (SendCommandToAllTabs.vbs):

Dim nIndex
Dim g_objTab
Dim g_szSkippedTabs
Dim g_szLogFile
Dim g_szTabCaption

For nIndex = 1 to crt.GetTabCount
    Set objCurrentTab = crt.GetTab(nIndex)
    objCurrentTab.Activate
    
    ' Skip tabs that aren't connected
    if objCurrentTab.Session.Connected = True then
        g_szTabCaption = objCurrentTab.Caption
        
        g_szLogFile = "C:\TEMP\" & g_szTabCaption & ".log"
        objCurrentTab.Session.LogFileName = g_szLogFile
        
    else
        if g_szSkippedTabs = "" then
            g_szSkippedTabs = nIndex
        else
            g_szSkippedTabs = g_szSkippedTabs & "," & nIndex
        end if
    end if
Next

Open in new window


Hope this help.
0
 

Author Closing Comment

by:cpatte7372
ID: 37786513
Cheers
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
The viewer will learn how to dynamically set the form action using jQuery.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question