Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #16  
Old 12-11-2008, 04:51 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
Hi dservin,

Since you are trying to connect using different protocols, I would suggest using WaitForStrings since you can wait for multiple strings that may vary depending on the device to which you are connecting, and the protocol you are using.

It may be helpful to replace the following line of code:
'crt.Screen.WaitForString "ogin:"
with
crt.Screen.WaitForStrings ("ogin:", "ser:")
do you see better behavior?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #17  
Old 12-25-2008, 08:50 PM
sduru sduru is offline
Registered User
 
Join Date: Jul 2008
Posts: 2
Not working

Hi,
When i run the script, i'm taking the error message below.. What can be the reason??

Error: Subscript out of range:'[number:1]'
Line:203
Reply With Quote
  #18  
Old 12-26-2008, 10:42 AM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 585
Hi sduru,

Which VanDyke product are you using?

The error you reported usually means you tried to access an element of an array that was either greater than its ubound or lower than its lbound. For example, the following code would produce this error:

Code:
Dim vMyArray(2)
MsgBox vMyArray(3)
Using this information are you able to determine the error in your script?

If not, could you provide the script code you are running and explain how it is being launched?
Reply With Quote
  #19  
Old 12-26-2008, 03:02 PM
sduru sduru is offline
Registered User
 
Join Date: Jul 2008
Posts: 2
ssh2 problem

Hi,
im using secure_crt 6.0.2 to connect a router. and i want to make an autoconnection to that rotuer and back-up a configuration file.but the connection is ssh2 and i cant use my previous scripts fot that connection. I've tried the script which dservin posted..is'nt it suitable for my problem??

The Error message is sourced from the line below...

if UBound(vElements) > 1 and vElements(ID_HOST) = varKey and _
vElements(ID_USER) = varUsername then
Reply With Quote
  #20  
Old 12-27-2008, 10:15 AM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 585
Hi sduru,

An example script that you may be able to use to generate a solution specific to your environment is below:

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

Dim g_fso, g_shell
Set g_fso = CreateObject("Scripting.FileSystemObject")

Const ForReading   = 1
Const ForWriting   = 2
Const ForAppending = 8

Dim g_szLogFile, g_szFirstLogFilePath, objTab

' Now we'll set our log file to something similar to the following:
'    c:\lablogs\12-27-2008 Results.txt
g_szLogFile = "c:\ " & Replace(Date, "/", "-") & " Results.txt"

Set objTab = crt.GetScriptTab

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

    objTab.Screen.IgnoreEscape = True
    objTab.Screen.Synchronous = True
   
    ' First make sure we're connected. If we're not worried about 
    ' whether we're connected or not then the follow 'if' statement can be removed.
    If Not objTab.Session.Connected then
        objTab.Session.Connect "/ssh2 MyServer"
    end if

    ' Send our command, and related commands
    objTab.Screen.Send "sho run" & vbcr

    Dim szResult

    ' Capture the results of the command with ReadString() into the 'szResult' variable
    szResult = objTab.Screen.ReadString(">")

    ' Open up our logfile
    Dim objFile
    Set objFile = g_fso.OpenTextFile(g_szLogFile, ForWriting, True)

    ' Write the results of our command to the log file
    objFile.WriteLine szResult

    ' Close the file so we don't leave a handle to it indefinitely
    objFile.Close

End Sub

Using this information are you able to develop a script that will perform as you have described?

If not, could you provide the script you are running after it has been modified, as well as any errors that are occurring when the script is run?
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 01:25 AM.