jamiecaesar / securecrt-tools

SecureCRT scripts, written in Python, for doing various tasks when connected to Cisco equipment.
Apache License 2.0
247 stars 77 forks source link

Master #6

Closed methridge closed 9 years ago

methridge commented 9 years ago

Fixed call typo

jamiecaesar commented 9 years ago

Oops. I made the correction on the previous pull request. I guess I'll see what happens when I try to merge this in :)

jamiecaesar commented 9 years ago

So, have either of you guys run into problems where SecureCRT really starts to bog down and sometimes eventually just crashes when trying to capture large inputs. I first noticed it when trying to capture a "show tech" which is multiple MB of text, but I'm also seeing it in the new Document_Device script when getting "show log" that has a large buffer size.

I think it has to do with SecureCRT having to put so much data in a variable, and it seems like it might be better to try and capture a few lines at a time and write those to disk, but I haven't dug into the best way to do that (or if it even works well -- that is more of a C way of doing things vs Python, I suppose).

methridge commented 9 years ago

I haven't seen the issue yet, but was suspecting I would. I'm wondering if the built in logging function would be better to use in this case (i.e. open and close log files for each command). May not be as efficient overall, but would probably handle the massive variable sizes.

So convert the file write with variable to something like this

crt.Session.LogFileName = fullFileName crt.Session.Log(True)

Have to play with how to not log invalid commands.

jamiecaesar commented 9 years ago

I also haven't upgraded my SecureCRT from Version 7.2, so I wonder if there could be a bug in it, if you haven't seen the problem. I should probably try that first.

methridge commented 9 years ago

Either works. I can make a quick change to the script to do the logging and you can test. See if that helps.

jamiecaesar commented 9 years ago

7.3.3 didn't fix the issue. Although I do see there is an example on VanDyke's site of how to read lines from the output and write them to the file. That may be a better option to changing the log file (since I have all my sessions logging by default, so you'd have to capture the old settings, change them to log the output and then put them back afterwards).

jamiecaesar commented 9 years ago

Here is their example: https://www.vandyke.com/support/securecrt/scripts/getdata_to_file.py.txt I'll probably give this a shot if you don't beat me to it. I'm working on a Master's degree and have 3 kids (7 and under) so my free time is limited with a midterm coming up on Friday. But not being able to capture a "show tech" or a long "show log" is kind of annoying, so I definitely want to get that fixed :)

methridge commented 9 years ago

Gotcha. I'm at Cisco Live! this week, so booked here as well.

jamiecaesar commented 9 years ago

I fixed it. I'm making the code look for either CRLF or the prompt after issues a command. If a CRLF is found, it will write the line to the file, or else it found the prompt and it needs to close the file. I've applied the fix to the scripts where needed (The ones that need to capture the entire output to process, like CDP, don't need it), except for the Document_Device script. That will need some additional changes to account for when a command doesn't exist, but I'll work on that too.

methridge commented 9 years ago

Awesome!!! Glad it was a fairly easy fix.

jamiecaesar commented 9 years ago

Me too. It just took a little digging in the documentation (which is for VBScript, but seems to have the same functionality). I was able to capture a 5.3MB "show tech" output without any slowdown -- just blurred past in the window.

On Tue, Jun 9, 2015 at 7:12 PM, garibaldi0 notifications@github.com wrote:

Gotcha. I'm at Cisco Live! this week, so booked here as well.

— Reply to this email directly or view it on GitHub https://github.com/jamiecaesar/SecureCRT/pull/6#issuecomment-110529613.

methridge commented 9 years ago

Very nice! I found that the windows version help has both the VBscript and Python examples in it. No idea why they don't include in the Mac version.

On Tue, Jun 9, 2015 at 6:07 PM, Jamie Caesar notifications@github.com wrote:

Me too. It just took a little digging in the documentation (which is for VBScript, but seems to have the same functionality). I was able to capture a 5.3MB "show tech" output without any slowdown -- just blurred past in the window.

On Tue, Jun 9, 2015 at 7:12 PM, garibaldi0 notifications@github.com wrote:

Gotcha. I'm at Cisco Live! this week, so booked here as well.

— Reply to this email directly or view it on GitHub <https://github.com/jamiecaesar/SecureCRT/pull/6#issuecomment-110529613 .

— Reply to this email directly or view it on GitHub https://github.com/jamiecaesar/SecureCRT/pull/6#issuecomment-110550105.

jamiecaesar commented 9 years ago

Maybe I overlooked that. This is the "Scripting Essentials" guide which is for VBScript which would have to be Windows. Oh well.. got me what I needed either way! :)

Enjoy Cisco Live. I was out there last year, but didn't make it this year. Didn't ask to go though -- didn't want to be greedy when others on the team would enjoy going also.

On Tue, Jun 9, 2015 at 9:08 PM, garibaldi0 notifications@github.com wrote:

Very nice! I found that the windows version help has both the VBscript and Python examples in it. No idea why they don't include in the Mac version.

On Tue, Jun 9, 2015 at 6:07 PM, Jamie Caesar notifications@github.com wrote:

Me too. It just took a little digging in the documentation (which is for VBScript, but seems to have the same functionality). I was able to capture a 5.3MB "show tech" output without any slowdown -- just blurred past in the window.

On Tue, Jun 9, 2015 at 7:12 PM, garibaldi0 notifications@github.com wrote:

Gotcha. I'm at Cisco Live! this week, so booked here as well.

— Reply to this email directly or view it on GitHub < https://github.com/jamiecaesar/SecureCRT/pull/6#issuecomment-110529613 .

— Reply to this email directly or view it on GitHub <https://github.com/jamiecaesar/SecureCRT/pull/6#issuecomment-110550105 .

— Reply to this email directly or view it on GitHub https://github.com/jamiecaesar/SecureCRT/pull/6#issuecomment-110550268.