#1
|
|||
|
|||
![]()
Hi.
Scripting is not my field so I'm having issues with making a script. This is the situation: I'm connected to the system and authorized. I want to connect to several RBSs and get alarms from them. Basically I need to do this on for each node: Code:
crt.Screen.Send "amos nodeID" & chr(13) crt.Screen.WaitForString "[0m> " crt.Screen.Send "alt" & chr(13) crt.Screen.WaitForString "[0m> " crt.Screen.Send "q" & chr(13) Some help would be appreciated. |
#2
|
|||
|
|||
Hi aqelmo,
Version of SecureCRT? Quote:
Please list the *explicit* steps as to how you would accomplish the task manually.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Hi,
Unfortunately, I'm using a really old version, 6.1.4. Apparently "it's working and you don't need a new one". It's Ericsson system for managing radio base stations. Literally what I need to do is: amos node1 (connect to node node1) al (list alarms) q (disconnect) amos node2 al q amos node3 al q . . . I would also append to separate log files for each node, that I know how to do. |
#4
|
|||
|
|||
Hi aqelmo,
It is still not clear to me if you are connected to the nodes or need to connect in the script. If already connected, it is fairly easy to iterate over the connected tabs with a For/Next loop: Code:
Sub Main() Do ' Iterate through all tabs, running commands For i = 1 To crt.GetTabCount Set objTab = crt.GetTab(i) ' Run Commands and disconnect Next Loop End Sub
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#5
|
|||
|
|||
Hi.
I'm initially connected to the management system (jump host?) and then within the same session connect, issue commands and disconnect from managed nodes. If I record the session as a script it looks like this: Code:
Sub Main crt.Screen.Send "amos 0001" & chr(13) crt.Screen.WaitForString "[0m> " crt.Screen.Send "al" & chr(13) crt.Screen.WaitForString "[0m> " crt.Screen.Send "q" & chr(13) crt.Screen.WaitForString chr(126) & "]$ " crt.Screen.Send "amos 0002" & chr(13) crt.Screen.WaitForString "[0m> " crt.Screen.Send "al" & chr(13) crt.Screen.WaitForString "[0m> " crt.Screen.Send "q" & chr(13) crt.Screen.WaitForString chr(126) & "]$ " crt.Screen.Send "amos 0003" & chr(13) crt.Screen.WaitForString "[0m> " crt.Screen.Send "al" & chr(13) crt.Screen.WaitForString "[0m> " crt.Screen.Send "q" & chr(13) End Sub Code:
Sub Main crt.Screen.Send "amos 0001" & chr(13) <- connect to node 0001 crt.Screen.WaitForString "[0m> " <- node prompt crt.Screen.Send "al" & chr(13) <- send command crt.Screen.WaitForString "[0m> " <- node prompt crt.Screen.Send "q" & chr(13) <- send disconnect command crt.Screen.WaitForString chr(126) & "]$ " <- management system prompt crt.Screen.Send "amos 0002" & chr(13) <- connect to node 0002 crt.Screen.WaitForString "[0m> " <- node prompt crt.Screen.Send "al" & chr(13) <- send command crt.Screen.WaitForString "[0m> " <- node prompt crt.Screen.Send "q" & chr(13) <- send disconnect command crt.Screen.WaitForString chr(126) & "]$ " <- management system prompt crt.Screen.Send "amos 0003" & chr(13) <- connect to node 0003 crt.Screen.WaitForString "[0m> " <- node prompt crt.Screen.Send "al" & chr(13) <- send command crt.Screen.WaitForString "[0m> " <- node prompt crt.Screen.Send "q" & chr(13) <- send disconnect command End Sub Last edited by aqelmo; 03-25-2020 at 12:41 AM. |
#6
|
|||
|
|||
Hi aqelmo,
How do you know what that first send is going to be? Is it always amos 0001, amos 0002, amos 0003? If not, where do you get the data from? How do you know what node(s) you will connect to? Because even in a script, you have to know how to determine what to send, if that makes sense. ![]() If just the three … Code:
For i = 1 to 3 crt.Screen.WaitForString chr(126) & "]$ " crt.Screen.Send "amos 000" & i & chr(13) crt.Screen.WaitForString "[0m> " crt.Screen.Send "al" & chr(13) crt.Screen.WaitForString "[0m> " crt.Screen.Send "q" & chr(13) Next
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 Last edited by bgagnon; 03-25-2020 at 08:19 AM. Reason: Put WFS in loop |
#7
|
|||
|
|||
Hi.
There are a few hundred nodes. I can export the list of nodes and get a file with single node ID per line. That should be an OK format for import? Since the list of nodes changes over time, it would be best to have it separately and not hardcoded into the script. |
#8
|
|||
|
|||
Hi aquelmo,
So are all worked on at the same time? Or could it be amos 0015 to amos 0102, for example, at any given time? If so, you can prompt the user for which nodes they will be working on (assuming they all have the amos prefix). Or you could pass those as arguments to the script.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#9
|
|||
|
|||
After a lot of try and error, I managed to hack something that does what I want to do.
stop logging my session loop connect to node get alarms append to log file for that node quit stop logging end loop start logging my normal session Now I need to get it to populate hosts aray from a file, instead of hardcoding it. But coffee 1st. Code:
# $language = "VBScript" # $interface = "1.0" g_strLogFileTemplate = "C:\path\Log\NODEID.txt" crt.Screen.Synchronous = True vHosts = Array(_ "0001",_ "0002",_ "0003") nIndex = 0 crt.Session.Log False Do Do crt.Screen.Send "amos " & vHosts(nIndex) & chr(13) crt.Screen.WaitForString "[0m> " crt.Screen.Send "alt" & chr(13) crt.Session.LogFileName = Replace( _ g_strLogFileTemplate, _ "NODEID", _ vHosts(nIndex)) crt.Session.Log True, True crt.Screen.WaitForString "[0m> " crt.Session.Log False crt.Screen.Send "q" & chr(13) crt.Screen.WaitForString chr(126) & "]$ " Exit Do Loop nIndex = nIndex + 1 If nIndex > Ubound(vHosts) Then Exit Do Loop crt.Session.LogFileName = "C:\path\logs\%Y.%M.%D - %S_ENM.log" crt.Session.Log True, True Last edited by aqelmo; 03-27-2020 at 10:15 AM. |
#10
|
|||
|
|||
Hi aqelmo,
Congrats on your progress! The previously referenced script (RunCommandsOnMultipleHostsAndLogResults) illustrates reading from a file. I understand when users feel a script has "more than they need" but it can still be used to borrow the relevant pieces of code. ![]()
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#11
|
|||
|
|||
I'm looking at it atm.
That and scripting essentials pdf. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|