|
![]() |
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
Dear all,
I have very limited knowledge of coding however I have searched through a few forum results and I am using sCRT from past 2 months and would like to customize it as per my needs. Is there a sample script you can provide which I use on the button which checks a pattern of the saved session hostname like "dccore" and logs in them and run a few commands on them like "show interface | i notconnect" , "show vlan brie" and "show version" and saves the output in a file for all of them or present them in the sCRT tabs? Please be patient as my understanding is very limited as beginer in coding world. Thanks, Faiz |
#2
|
|||
|
|||
Hi Faiz,
What version of SecureCRT are you using? On what OS/platform?
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
This happens to me too.
I tried the recorder function and it works fine for the easy steps. (paste the line per line my commands) so my last command is quite tricky. I tried to save the startup-config from my device to an ftp server. What I need is a short scriptline to insert the hostname in my command. Command looks: copy nvram startup-config tftp 62.xxx.xxx.xxx config/cmts/<hostname>-confg I have 200 devices and in the past I entered my commands line per line manually. Since last week i use secureCRT and try to automate some worksteps. Hope find someone with fun to help me. :-) I use secureCRT 8 and MAC OS X el Capitan. |
#4
|
|||
|
|||
Hi Sascha,
I am not sure it answers Faiz's inquiry, but for yours, you can use SessionConfiguration object. See SecureCRT's Help file topic Scripting / Script Objects Reference / SessionConfiguration Object. Any session INI option that is preceded by S (string), Z (multi-string) or D (DWORD) can be *set* (SetOption) or *returned* (GetOption) via this object, using those methods. For example, in Python, you might have: Code:
objTab = crt.GetScriptTab() objConfig = objTab.Session.Config strHostname = objConfig.GetOption("Hostname") objTab.Screen.Send("copy nvram startup-config tftp 62.xxx.xxx.xxx config/cmts/" + strHostname + "-confg\r\n")
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#5
|
|||
|
|||
![]()
Hi Brenda,
I am trying to post but reply is not appearing in the main console. sCRT = Version 7.2.6 (x64 build 606) - Official Release - August 19, 2014 Windows = 8.1 64 bit Regds Faiz |
#6
|
|||
|
|||
Hi Faiz,
Quote:
![]() Quote:
Is there going to be a "hard-coded list" to match against? Or will it be more dynamic, such as "starts with dcc"?
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#7
|
|||
|
|||
Hi Brenda,
This is what I am looking to achieve. Q: What do you mean "checks a pattern of ... the hostname"? Ans: I have plenty saved sessions in the sCRT console, those I am talking about to be cross checked against the hostname pattern. Q: Is there going to be a "hard-coded list" to match against? Ans: All the sessions in the saved list should be checked against the pattern "dccore" in their hostname field and as soon as they find a match they should hit login and try to run come commands. Q: Or will it be more dynamic, such as "starts with dcc"? Ans: could be "starts with or contains" <dccore> as pattern , match against the saved sessions hostnames and based on the match run a login script with some commands. Regds, Faiz |
#8
|
||||
|
||||
Faiz,
SecureCRT doesn't provide a way to natively iterate through the sessions saved in the Session Manager, but I've created a feature request so that this might be possible for you to accomplish natively within SecureCRT's scripting API. In the mean time, if you're brave, and you have a default configuration, you can get a reference to the configuration folder by querying the registry, then using the file system object to iterate over your existing session.ini files to perform a pattern match on the actual session.ini file name. We don't have a concrete example of how to do this yet, but if time allows, we may post in the future an example of how this might be done. --Jake
__________________
Jake Devenport VanDyke Software Technical Support YouTube Channel: https://www.youtube.com/vandykesoftware Email: support@vandyke.com Web: https://www.vandyke.com/support |
#9
|
|||
|
|||
Hi Jake, Brenda,
Thats really nice of you to accomodate this feature enhancement in the tool for future. However do you have any sort of example where it can do the checks on current "session.ini" file? if not, can it check the hostname in any other format like pattern match in an .xlsx file? Regds, Farhan J. |
#10
|
|||
|
|||
Hi Farhan,
In that case, to check current session's hostname, the information posted in response to Sascha's inquiry in this same thread is relevant.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#11
|
|||
|
|||
hi Brenda,
I have tried to use that script but it hasnt done anything. Do I need to modify it and save it with some different extension to make it work? Regds, Faiz |
#12
|
|||
|
|||
Hi Faiz,
Yes, it's a Python example, so you would use ScriptName.py. A VBScript version would not be all that different (ScriptName.vbs): Code:
Set objTab = crt.GetScriptTab Set objConfig = objTab.Session.Config strHostname = objConfig.GetOption("Hostname") MsgBox "Hostname is: " & strHostname
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#13
|
|||
|
|||
Sorry guys that didnt work either.
|
#14
|
|||
|
|||
Hi faiz_usmani,
Please elaborate on what you mean by "didn't work either". Did you get an error? (If so, what is the error?) Did the command you expected to be sent to the remote not get sent? Or ... some other issue occurred?
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
![]() |
Thread Tools | |
Display Modes | |
|
|