Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-14-2015, 07:08 PM
tuanvu0695 tuanvu0695 is offline
Registered User
 
Join Date: Dec 2015
Posts: 4
Update Excel from crt secure by scripting

hi all, im new to crt, recently i have created a sub to save screen and update it to excel,however base on vandyke sample i just can overwrite the excel file, is there any ideas that i can update the excel file whenever i run the script? here is my script:
# $language = "VBScript"
# $interface = "1.0"

' This script demonstrates how ActiveX scripting can be used to
' interact with CRT and manipulate other programs such as Microsoft Excel
' through an OLE automation interface. This script creates an instance of Excel,
' then it sends a command to a remote server (assuming we're already
' connected). It reads the output, parses it and writes out some of the
' data to an Excel spreadsheet and saves it. This script also demonstrates
' how the WaitForStrings function can be used to wait for more than one
' output string.

Sub main

crt.screen.synchronous = true

' Create an Excel workbook/worksheet
'
Dim app, wb, ws
Set app = CreateObject("Excel.Application")
Set wb = app.Workbooks.Add
Set ws = wb.Worksheets(1)

crt.Screen.Send "en" & chr(13)

crt.Screen.Send "conf t" & chr(13)
crt.Screen.Send "do sh env all" & chr(13)

envStartString = "Switch(config)#do sh env all"
envEndingString = "Switch(config)#"
Set objTab1 = crt.GetScriptTab
if objTab1.Screen.WaitForString(envStartString, 30) = False then
MsgBox "We never found the """ & envStartString & """ string indicating " & _
"that we should begin the ReadString call. We will now exit the script"
Exit Sub
end if
envResult = objTab1.Screen.ReadString(envEndingString, 60)
MsgBox envResult

ws.Cells(2, 1).Value = envresult
'ws.Cells(row, 2).Value = items(2)



wb.SaveAs("C:\Users\Harry\Desktop\New folder\savetoexcel.xlsx")
wb.Close
app.Quit

Set ws = nothing
Set wb = nothing
Set app = nothing

crt.screen.synchronous = false

End Sub

thanks,
Reply With Quote
  #2  
Old 12-15-2015, 07:16 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,938
Hi tuanvu0695,

I am not sure where you found the example you posted, but I am confident one of these example scripts can help you to accomplish your objective.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 01-04-2016, 09:30 PM
tuanvu0695 tuanvu0695 is offline
Registered User
 
Join Date: Dec 2015
Posts: 4
Talking

thanks bgagnon, that solves my problem, thats all i need.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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:34 AM.