Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-15-2013, 08:39 AM
gunslingor gunslingor is offline
Registered User
 
Join Date: May 2013
Posts: 27
VBscript SecureCRT Run Outside

Here's my first simple script I have a questions about:

Code:
Language="VBScript"
Interface="1.0"

call Main

Sub Main()
	Run "C:\Program Files\VanDyke Software\SecureCRT\SecureCRT.exe"
	'crt.Session.Connect "/Serial COM6 /BAUD 9600"
End sub

Sub Run(ByVal sFile)
	Dim shell
	Set shell = CreateObject("WScript.Shell")
    shell.Run Chr(34) & sFile & Chr(34), 1, false
    Set shell = Nothing	
End Sub
The script runs well when [crt.Session.Connect "/Serial COM6 /BAUD 9600"] is commented out as shown above, and fails when its not commented out.

I suspect because crt.whatever is only interpretable when you actually "Run" the script from within secureCRT, is that right?

Ideally, I'd like to be able to just double click on the script (as I'm doing now) and have it open CRT and then be able to do what I want. Is this possible, or do you have to run it from within CRT?
Reply With Quote
  #2  
Old 05-15-2013, 10:46 AM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,039
Quote:
I suspect because crt.whatever is only interpretable when you actually "Run" the script from within secureCRT, is that right?
Correct. The SecureCRT API (the crt object) is not externally exposed. Only SecureCRT knows about it, so SecureCRT must be used to run the script.

I have added your forum post to our request database and if we expose the API in a future release we'll post a follow up message to this thread. If you'd like to receive email notification please let us know and refer to forum thread 11022.

Would it be helpful if SecureCRT automatically ran the script when you start it, so that instead of double clicking the script you just double click a particular SecureCRT icon?
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #3  
Old 05-15-2013, 12:39 PM
gunslingor gunslingor is offline
Registered User
 
Join Date: May 2013
Posts: 27
Code:
Would it be helpful if SecureCRT automatically ran the script when you start it, so that instead of double clicking the script you just double click a particular SecureCRT icon?
I'd probably approach it differently, making it as dynamic and seamless with other applications as possible.

What I'd "like" to do is to be able to write an application, say in MS Access or perhaps many other platforms, that can interface easily with secureCRT.

I mean, currently I'm working on this script to grab some basic configuration data from cisco devices, then I need to import this into an Access DB so we can filter and sort on the data, track changes, etc. Right now its looking like I'm going to need to write a script for secureCRT (perhaps multiple for each model we have because the commands can be different-later). This script will do a lot of show commands, parsing of the output (like pulling version 12.2(SE1)55) out of the output, and sending it to a text file. Then in my access DB, I'll need some kind of importing, and maybe more parsing, code that will pull the text file data into my DB...

Ideally, their should be a way to do this such that my users will only need to press one button to run all this from within my access DB (one of the goals of my job function is tool integration). So, in effect, they'd press the button in access and it'll run the VB code. The first item in the code would probably be 'open CRT'.... if there was a way to pass arguments on this open command, like the location of the script file, then the script could run when its open... so rather than running a script on open like you suggest, make CRT accept a script location argument when its opened using code. How to then pass control back to Access, or similar, after the script runs, I'm not sure that'll be easy to accomplish... so perhaps there's just a way to turn secureCRT into an axtiveX control or to expose the API to the OS... in all honestly, and ideally, I would love to have all the functionally of secureCRT without having to actually use the front end...or perhaps a way to integrate the frontend and API with other applications. Make sense?

I'm a computer engineer, but I do currently feel like a noob as this is my first adventure with secureCRT and networking.

Last edited by gunslingor; 05-15-2013 at 12:44 PM.
Reply With Quote
  #4  
Old 05-15-2013, 02:08 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,039
One of the command-line options that SecureCRT supports is /SCRIPT.
SecureCRT.exe /SCRIPT "C:\Some Path\Your Script.vbs"
You might also consider using SecureCRT's Logon script option (Session Options / Connection / Logon Actions).
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #5  
Old 05-16-2013, 05:20 AM
gunslingor gunslingor is offline
Registered User
 
Join Date: May 2013
Posts: 27
Cool, I'll give that a try once I get the code further along.
Reply With Quote
Reply

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 06:09 PM.