View Single Post
  #3  
Old 01-19-2006, 10:08 AM
tnygren's Avatar
tnygren tnygren is offline
Registered User
 
Join Date: May 2005
Posts: 1,408
Hi Gamma,

This is possible using the scripting objects in SecureCRT.

I have provided an example VBscript below that will start a session and run a command.

The script does need the SecureCRT window to be already open but it sounded like you have already created that portion of the script.

Code:
#$language = "VBScript"
#$interface = "1.0"
Option Explicit

' Modify the g_szCommand string below to send the command you want
' Modify the g_szSession to the session name that needs to be connected to
Dim g_szCommand, g_szPrompt, g_szSession

g_szSession = "redhat"
g_szCommand = "ps -auuux | grep $USER" & vbcr
g_szPrompt  = "->"

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub Main()

    ' Connect to the session

    crt.Session.Connect("/S " & chr(34) & g_szSession & chr(34))

    ' Issue the command that will generate the output that we are looking for
    crt.Screen.Send g_szCommand

    ' Wait for the command to finish (the prompt will appear when the command
    ' is done)
    crt.Screen.WaitForString(g_szPrompt)

    ' Now Quit SecureCRT
    crt.Sleep 250
    crt.Quit

End Sub
To start this script from the SecureCRT command line, just add the following to the SecureCRT command line:

SecureCRT.exe /Script <full path to script file\script name>

Was this the information that you needed?
__________________
Thanks,

Teresa

Teresa Nygren

Last edited by tnygren; 01-19-2006 at 02:29 PM.