Oct-07-2019, 01:08 PM
I mentioned a few times before that I am trying to learn/get better at python.
I am unable to load non standard modules.
I am using either python 2.6.6 or 2.7 (mostly 2.6.6)
To get a better handle on Python, I am trying to port my shell script over.
I ran into a snag. I have a shell script that cuts the following output from a log, then counts the number of
My bash script uses sed and grep to determine whether the device log Im looking at shows a stacked switch or not.
Sed
The Sed response
I put the sed response in a var then perform if .. if larger than 3 I have a stacked switch.
My question is ..
How do I grab chunks of text with Python then count lines ?
I am unable to load non standard modules.
I am using either python 2.6.6 or 2.7 (mostly 2.6.6)
To get a better handle on Python, I am trying to port my shell script over.
I ran into a snag. I have a shell script that cuts the following output from a log, then counts the number of
Quote:Stack# show version
Switch Ports Model SW Version SW Image
------ ----- ----- ---------- ----------
* 1 30 WS-C3750E-24PD 12.2(46)SE C3750E-UNIVERSAL-M
2 28 WS-C3750E-24PS 12.2(46)SE C3750E-UNIVERSAL-M
3 54 WS-C3750E-48TD 12.2(46)SE C3750E-UNIVERSAL-M
My bash script uses sed and grep to determine whether the device log Im looking at shows a stacked switch or not.
Sed
Quote:sed '/^Switch/,/^$/!d' xxx.log | grep -c "^"
The Sed response
Quote:6
I put the sed response in a var then perform if .. if larger than 3 I have a stacked switch.
My question is ..
How do I grab chunks of text with Python then count lines ?