Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #46  
Old 02-29-2012, 03:04 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
Hi stuartX,

I reviewed the phone notes and prior forum posts you had with Todd and it seems you are using an older version of SecureCRT, while all our tests have been with the current release.

Based on the serial number provided, you should be eligible to upgrade to the current release, version 6.7.4. We would like you to do that before we go too much further. For one thing, v6.0.x always reported script errors "one line off" and that is counter-productive to resolving problems that occur when running the script.

You can check your upgrade eligibility here.

Also, do you connect to any of these devices with anything but Telnet protocol?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #47  
Old 03-01-2012, 05:09 AM
stuartX stuartX is offline
Registered User
 
Join Date: Feb 2012
Posts: 33
I now have version 6.7.4 and it doing the same thing.
stuart
Reply With Quote
  #48  
Old 03-01-2012, 11:18 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
Hello stuartX,

No worries. We did not expect it to resolve the issue, it's just a good idea to be running the current release if possible.

You overlooked one question:

Quote:
Also, do you connect to any of these devices with anything but Telnet protocol?
I ask because it looks like you started with a script you found on another forum thread and it is overcomplicated for what you need to accomplish if you are only connecting to devices using Telnet protocol. We would like to streamline the existing script accordingly if that is the case.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #49  
Old 03-01-2012, 11:44 AM
stuartX stuartX is offline
Registered User
 
Join Date: Feb 2012
Posts: 33
No problem, its good to be up on the current version.
Telnet is the only protocol used to access the devices.
Reply With Quote
  #50  
Old 03-01-2012, 05:26 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
Hi stuartX,

The revised script is below.

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

Sub Main
    strUsername = "user" 'not real username
    strPassword = "password" 'not real password
    strPrompt = "#"
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    strDeviceList = "s:\riggs\Test-router-1.txt"
    Set fil = fso.OpenTextFile(strDeviceList)
    
    ' Start loop to iterate over all devices defined in file
    While Not fil.AtEndOfStream
    
        ' Process a line at a time
        vLine = Split(fil.ReadLine, ";")
        strHostname = vLine(0)
        strIP = vLine(1)
        On Error Resume Next
            crt.Session.Connect cnxnString
            strErr = Err.Description
            nError = Err.Number
        On Error Goto 0        
        If crt.Session.Connected = False Then 
            crt.Dialog.MessageBox "The following host cannot be reached: " &_
            vbcrlf & vbtab & strHostname & vbcrlf & vbcrlf &_
            "With error: " & vbcrlf & vbtab & strErr
        Else
        
            ' Enable Synchronous which is necessary to avoid missing data from
            ' remote
            crt.Screen.Synchronous = True
            
            crt.Screen.WaitForString "login:"
            crt.Screen.Send strUsername & vbcr
            crt.Screen.WaitForString "Password:"
            crt.Screen.Send strPassword & vbcr

            ' Confirm that remote is ready
            crt.Screen.WaitForString strPrompt
            
            ' Start logging to new file
            strLogFile = "S:\Riggs\" & strHostname & "-%Y-%M-%D--%h-%m-%s.%t.txt"
            crt.Session.LogFileName = strLogFile
            crt.Session.Log True
            
            ' Turn off paging
            crt.Screen.Send "term length 0" & vbcr	
            crt.Screen.WaitForString strPrompt
            
            ' Send commands
            crt.Screen.Send "show proc cpu | inc CPU" & vbcr
            crt.Screen.WaitForString strPrompt
            crt.Screen.Send "show version" & vbcr 
            crt.Screen.WaitForString strPrompt
            
            ' Stop logging
            crt.Session.Log False
            
            ' Disconnect from device
            If crt.Session.Connected Then
                crt.Session.Disconnect
            End If
        End If
    Wend
    
    ' Close device file
    fil.Close 
End Sub
If you still get odd results with this version (ie: first time through succeeds, but later iterations seem to be "out of sync"), I would suggest capturing raw logs of maybe two or three of the various devices so we can see what the remote is sending.

To create a raw log:
  • Before connecting with the session, select Raw Log Session from SecureCRT's File menu.
  • In the Select Log File dialog, choose a folder and filename in which you would like the log text to be stored and press the Save button. At this point, if you open the File menu, you will notice that the Raw Log Session menu item now has a check-mark next to it; this indicates that raw logging is activated.
  • Now connect to the remote machine and perform the same actions you are trying to automate.
  • Once the you have completed the manual tasks, disconnect the session and select Raw Log Session from the File menu to turn off the raw logging feature.
Since a raw log can contain sensitive information, feel free to send it as an attachment via e-mail to support@vandyke.com. Please reference "Attn Brenda - Forum Thread #10303" in the subject line.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #51  
Old 03-02-2012, 06:06 AM
stuartX stuartX is offline
Registered User
 
Join Date: Feb 2012
Posts: 33
@Brenda,
SSSwwwweeeettt!!!! That works consistently. Thank you very, very much.

@RTB, Thanks for all your help.

Stuart
Reply With Quote
  #52  
Old 03-02-2012, 09:25 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
@Stuart,

Thhaaaannnkkkksss!!

I am glad to hear the script is working for you.

I will pass along your message to Todd.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
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 12:44 PM.