#1
|
|||
|
|||
Scripting Firewall Sessions with Python
My current script is as follows:
Code:
def Main(): for X in range (1, crt.GetTabCount() + 1): Start = crt.GetScriptTab() CurrentTab = crt.GetTab(X) CurrentScreen = CurrentTab.Screen CurrentTab.Activate() Tab.Session.LogFileName = "C:\Users\O3278\Documents\Logs\Firewall Information %M-%D.log" CurrentScreen.Send("\r") CurrentScreen.Send("more system:running-config\r") if CurrentScreen.WaitForString("<--- More --->") == True: CurrentScreen.Send(" ") Main() I know this can be done because I've done it in VB. But what I'm encountering is the log file was being reset fine, but each session was trying to send the data at the same time. I was getting multiple copies of the file with a _1, _2, _3 appended to it. Now I've managed to get the script to cycle through the open tabs and send a CR in each tab. When I add the command to the script the command gets run multiple times in the script tab, but not in the other tabs. I'm wondering if the primary session is being overwhelmed. I'm going to try it with a crt.Sleep(3000) and see if the command gets issues to the other tabs. Or it may be that I need to increase the "Line Send Delay". Anyone have any ideas? |
#2
|
|||
|
|||
Hi Caoimhin,
Thanks for the post. I see that you are getting a CurrentTab object, but then when you set the log, you don't use the CurrentTab object. If you modify the line that logs to use CurrentTab, do you get better results? |
#3
|
|||
|
|||
Funny I was thinking the same thing. So the code was altered since my last post:
Code:
# $language = "python" # $interface = "1.0" def Main(): for X in range (1, crt.GetTabCount() + 1): Start = crt.GetScriptTab() CurrentTab = crt.GetTab(X) CurrentScreen = CurrentTab.Screen CurrentTab.Activate() CurrentScreen.Synchronous == True CurrentTab.Session.LogFileName = "C:\Users\O3278\Documents\Logs\Firewall Information %M-%D.log" if not crt.Session.Logging == True: crt.Session.Logging (True, True) CurrentScreen.Send("\r") CurrentScreen.Send("more system:running-config\r") for Y in range (1, 20): CurrentScreen.Send(" ") crt.Sleep(10000) CurrentTab.Session.LogFileName = "C:\Users\O3278\Documents\Logs\Firewalls\%S %M-%D.log" Main() |
#4
|
|||
|
|||
Hi Caoimhin,
You are now using the crt object rather than the CurrentTab object to determine if logging is enabled. Additionally, you are trying to set the Logging property which is read only. If you want to start logging, you would need to use the CurrentTab object and the Log() method. Does this help to resolve the issue? |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|