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 04-17-2009, 08:30 AM
ramvign ramvign is offline
Registered User
 
Join Date: Apr 2009
Posts: 5
running another script from current script

I need to run another vbscript from current script on Securecrt. Can anyone help me on this please?

Thanks
Ramesh
Reply With Quote
  #2  
Old 04-17-2009, 09:08 AM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,039
Hello Ramesh,

The following code shows how to run another program, in this case explorer.exe. Does this example help?

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

' Run.vbs demonstrates how to utilize the Windows Scripting Host (WSH) by using 
' its 'Run' method to execute other programs. Note the use of nested quotes to pass
' a path that contains spaces along with command line arguments.

Sub Main
  Dim shell, DownloadFolder
  Set shell = CreateObject("WScript.Shell")
  DownloadFolder = Crt.FileTransfer.DownloadFolder
  MsgBox DownloadFolder
  shell.Run """C:\Windows\Explorer.exe""" & " " & DownloadFolder
End Sub
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]

Last edited by miked; 04-17-2009 at 09:10 AM.
Reply With Quote
  #3  
Old 04-17-2009, 10:54 AM
ramvign ramvign is offline
Registered User
 
Join Date: Apr 2009
Posts: 5
Hi Michael

Thanks for the quick response. I guess the question I asked wasn’t clear. Here is what I need to do.
I have two scripts, one is “Driver.vbs” and other one is “Super_USR-Script.vbs”. What Driver.vbs supposes to do is select Tab on opened SecureCRT , activates and run Super_USR-Script.vbs then moves to next tab ( It shouldn’t wait till finish second script).

Here are the codes that I have.
---------------------------------------------------------------
Driver.vbs
---------------------------------------------------------------
#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = true

Sub Main

Dim x

for x = 1 to 8

Set objCurrentTab = crt.GetTab(x)
objCurrentTab.Activate
objCurrentTab.Screen.Synchronous = true
objCurrentTab.Screen.Send vbCr

'At this point, I need to call second script and move to next statement.
MsgBox "Super_USR-Script is running"
next

End Sub

------------------------------------------------------
Super_USR-Script.vbs
------------------------------------------------------
#$language = "VBScript"
#$interface = "1.0"
Option Explicit

Sub Main


crt.Screen.Synchronous = true

crt.Screen.Send("at%e=1")
crt.Screen.Send("\015")
crt.Screen.WaitForString( "OK" )
'and so on
'and so on
'and so on
'and so on
'and so on


End Sub
---------------------------------------------------------------

Thanks
Ramesh
Reply With Quote
  #4  
Old 04-17-2009, 12:45 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,039
Hi Ramesh,

It looks like you're wanting to have multiple tabs, each tab running a script, and if so there might be a couple ways to accomplish your goal.

Could you tell us a little about your overall goal?

Would you be interested in running a script which starts multiple SecureCRT connections in tabs, with each tab running a script?
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]

Last edited by miked; 04-17-2009 at 04:29 PM.
Reply With Quote
  #5  
Old 04-20-2009, 10:44 AM
ramvign ramvign is offline
Registered User
 
Join Date: Apr 2009
Posts: 5
Hi Michael,

Thanks for your reply.

Yes, I want to run a script on multiple tabs simultaneously.
Example:

I want to programme eight USR Modems simultaneously using one script and one click on Run (I don’t want to click run eight times on eight tabs). As I said on my previous note the script called “Driver” is a starter of second script which is for program USR Modems. The reason why I want to use two scripts is it takes time to programme a modem and move to next tab and do same thing.

Idea which I have may be long route. If there are any short cut methods to reach my goal, I am really interested to know. As you said running a script which starts multiple SecureCRT connections in tabs, with each tab running a script is good idea too.

Thanks
Ramesh
Reply With Quote
  #6  
Old 04-20-2009, 11:31 AM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,039
Quote:
running a script which starts multiple SecureCRT connections in tabs, with each tab running a script is good idea too.
Here are a pair of scripts that I believe will help. The first script launches SecureCRT using the /T parameter, which tells SecureCRT to open a new tab. It also uses /SCRIPT to tell SecureCRT to run a script in that new tab.

Code:
' ------------Launcher Script------------
' Runs outside SecureCRT
vSessions = Array(_
    "session 1", _
    "session 2", _
    "session 3")
    
Dim objShell
Set objShell = CreateObject("WScript.Shell")

For each strSession in vSessions
    objShell.Run "SecureCRT /T /S " & chr(34) & strSession & chr(34) & _
                 " /Script C:\temp\Tab-SpecificScript.vbs"
    WScript.Sleep 500
Next
Code:
'------------Tab-Specific Script------------
' Runs INSIDE securecrt (is passed as arg to /SCRIPT)
Set objTab = crt.GetScriptTab

objTab.Screen.Synchronous = True
objTab.Screen.Send vbcr
objTab.Screen.WaitForString vbcr
objTab.Screen.Send "cat -v" & vbcr
objTab.Screen.WaitForString vbcr

objTab.Screen.Send "at%e=1" & vbcr
objTab.Screen.WaitForString "at%e=1" & vbcr

' .
' .
' .
Does this example help?
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #7  
Old 04-22-2009, 12:39 PM
ramvign ramvign is offline
Registered User
 
Join Date: Apr 2009
Posts: 5
Hi Michael,

I tried to run Launcher.vbs from windows command prompt (cscript Launcher.vbs), but nothing happened not even error message. I had to modify the paths.

' ------------Launcher Script------------
' Runs outside SecureCRT
vSessions = Array(_
"session 1", _
"session 2", _
"session 3")

Dim objShell
Set objShell = CreateObject("WScript.Shell")

For each strSession in vSessions
objShell.Run "C:\Program Files\VanDyke Software\SecureCRT\SecureCRT.EXE /T /S " & chr(34) & strSession & chr(34) & _
" /Script C:\Documents and Settings\x112117\Desktop\comon pass\Tab-SpecificScript.vbs"
WScript.Sleep 500
Next

Thanks
Ramesh
Reply With Quote
  #8  
Old 04-22-2009, 02:11 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,039
Hi Ramesh,

I should have mentioned paths in my previous message.

Is the script working now that you've modified the paths?

The reason I ask is because I thought you would need chr(34) around the path to SecureCRT.
Code:
chr(34) & "C:\Program Files\...\SecureCRT.exe" & chr(34).
In my testing without the chr(34) around paths with spaces, VBScript pops up an error saying it cannot find the file specified.
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #9  
Old 05-05-2009, 10:13 AM
ramvign ramvign is offline
Registered User
 
Join Date: Apr 2009
Posts: 5
Hi Michael,

Thanks for your support. I have modified the Launcher.vbs as following and everything working fine now.

' ------------Launcher Script------------
' Runs outside SecureCRT
vSessions = Array("Switch1", "Switch2", "Switch3" )

Dim objShell
Set objShell = CreateObject("WScript.Shell")

For each strSession in vSessions
objShell.Run chr(34) & "C:\Program Files\VanDyke Software\SecureCRT\SecureCRT.exe " & chr(34) & "/T /S "& strSession & _
" /Script Message.vbs"
WScript.Sleep 2000
Next

Thanks
Ramesh
Reply With Quote
  #10  
Old 05-05-2009, 12:27 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,039
Hi Ramesh,

Thanks for posting the solution - I'm glad to hear your script is working now!
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #11  
Old 07-31-2013, 11:32 PM
emailsbecker emailsbecker is offline
Registered User
 
Join Date: Apr 2011
Posts: 74
Time to bring back an old thread!

I think the information here will take care of what I need, however there's one thing missing. I have my computer set up to associate .VBS files to be opened with UltraEdit by default. I do this for safety - if I were browsing files and accidentally opened a script while I was actively logged into a device in SecureCRT it could affect the device I'm logged into. If I need the script in Secure CRT, I run it from SecureCRT using ALT+S+R or the button bar.

So when I run the code above SecureCRT does indeed call the script, but instead of running it in the SecureCRT tab it opens it in UltraEdit. Really, I'd prefer to keep the file associations as they are. Is there a way to tell SecureCRT to open the script IN SecureCRT?

TIA!
Reply With Quote
  #12  
Old 08-01-2013, 12:45 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,633
Hello emailsbecker,

What script code are you currently using?

There were quite a few example script snippets posted in this thread. (I view most recent post at top, so there is nothing above.)
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #13  
Old 09-30-2013, 11:03 PM
emailsbecker emailsbecker is offline
Registered User
 
Join Date: Apr 2011
Posts: 74
I'm running 6.1.1 ... I believe this is out of date, and I've asked our IT department about whether or not I have permission to update it but they haven't gotten back to me.
Reply With Quote
  #14  
Old 10-01-2013, 09:23 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,633
Hello emailsbecker,

I am not sure the version of SecureCRT is going to have any bearing.

What script were you referring to?

What operating system is SecureCRT installed on?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #15  
Old 10-03-2013, 06:17 AM
emailsbecker emailsbecker is offline
Registered User
 
Join Date: Apr 2011
Posts: 74
Quote:
Originally Posted by bgagnon View Post
I am not sure the version of SecureCRT is going to have any bearing.
Then why did you ask?

This PC has Windows 7 Enterprise. The scripts I would be running would be ones I've written myself.
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 02:01 AM.