<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for DEVILWAH&#039;s BLOG</title>
	<atom:link href="http://www.devilwah.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devilwah.com</link>
	<description>CISCO, LINUX and all thing DEVILISH</description>
	<lastBuildDate>Tue, 10 Jan 2012 21:50:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>Comment on VB again by DevilWAH</title>
		<link>http://www.devilwah.com/2011/05/vb-again/#comment-244</link>
		<dc:creator>DevilWAH</dc:creator>
		<pubDate>Tue, 10 Jan 2012 21:50:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.devilwah.com/?p=957#comment-244</guid>
		<description>Hi, 

Sadly I am not a big user of Regex so can&#039;t really help with that. 

I suggest you go to a site called &quot;Stackoverflow.com&quot;

You will need to sign up by its a free forum for programmers and has a huge user base. There are not to many people on there using CRT, but for VBscript and any other programming language you can think of you will get an answer. 

I generally find I can get an answer of there in 30minutes or so, and I know from experience there are some good Regex experts there. 

Try there and please let me know what they say, if your interested in scripting and programming its worth having them bookmarked anyway. 

Hope that helps

DevilWAH</description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>Sadly I am not a big user of Regex so can&#8217;t really help with that. </p>
<p>I suggest you go to a site called &#8220;Stackoverflow.com&#8221;</p>
<p>You will need to sign up by its a free forum for programmers and has a huge user base. There are not to many people on there using CRT, but for VBscript and any other programming language you can think of you will get an answer. </p>
<p>I generally find I can get an answer of there in 30minutes or so, and I know from experience there are some good Regex experts there. </p>
<p>Try there and please let me know what they say, if your interested in scripting and programming its worth having them bookmarked anyway. </p>
<p>Hope that helps</p>
<p>DevilWAH</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on VB again by Manny</title>
		<link>http://www.devilwah.com/2011/05/vb-again/#comment-242</link>
		<dc:creator>Manny</dc:creator>
		<pubDate>Tue, 10 Jan 2012 21:33:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.devilwah.com/?p=957#comment-242</guid>
		<description>OK, I was playing with this today.  I tried to create a multi-Line Regex using the &quot;&#124;&quot; between them, but it appears that it is an &quot;OR&quot; instead of &quot;AND&quot;.  So I have some interfaces (Tunnel XX) that I do not want to include in this check.

Again, vConfigLines is an array from the output of a show run command on the Cisco device.

2 Things, the Regex is matching any instance of the regex after the &#124; and I am getting an out of range error.  If you can help, that would be great.

Regards.
It is failing 

vConfigLines = Split(strResultsINT, vbcr)

Set re = new RegExp
re.Global = False
re.IgnoreCase = True
re.Multiline = False
re.Pattern = &quot;interface\s[FG].*&quot;

Set re2 = new RegExp
re2.Global = False
re2.IgnoreCase = True
re2.Multiline = False
re2.Pattern = &quot;\sswitchport\saccess\svlan [0-9].+&#124;\sspanning-tree\sportfast&#124;\sswitchport\smode\saccess&quot;


Do While nCount 0 Then
	MsgBox &quot;Regex 2&quot; &amp; vConfigLines(nCount)
                else
	exit do
            end if
	nCount = nCount + 1
	loop
	Else
	nCount = nCount + 1
end IF
Loop</description>
		<content:encoded><![CDATA[<p>OK, I was playing with this today.  I tried to create a multi-Line Regex using the &#8220;|&#8221; between them, but it appears that it is an &#8220;OR&#8221; instead of &#8220;AND&#8221;.  So I have some interfaces (Tunnel XX) that I do not want to include in this check.</p>
<p>Again, vConfigLines is an array from the output of a show run command on the Cisco device.</p>
<p>2 Things, the Regex is matching any instance of the regex after the | and I am getting an out of range error.  If you can help, that would be great.</p>
<p>Regards.<br />
It is failing </p>
<p>vConfigLines = Split(strResultsINT, vbcr)</p>
<p>Set re = new RegExp<br />
re.Global = False<br />
re.IgnoreCase = True<br />
re.Multiline = False<br />
re.Pattern = &#8220;interface\s[FG].*&#8221;</p>
<p>Set re2 = new RegExp<br />
re2.Global = False<br />
re2.IgnoreCase = True<br />
re2.Multiline = False<br />
re2.Pattern = &#8220;\sswitchport\saccess\svlan [0-9].+|\sspanning-tree\sportfast|\sswitchport\smode\saccess&#8221;</p>
<p>Do While nCount 0 Then<br />
	MsgBox &#8220;Regex 2&#8243; &amp; vConfigLines(nCount)<br />
                else<br />
	exit do<br />
            end if<br />
	nCount = nCount + 1<br />
	loop<br />
	Else<br />
	nCount = nCount + 1<br />
end IF<br />
Loop</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on VB again by DevilWAH</title>
		<link>http://www.devilwah.com/2011/05/vb-again/#comment-237</link>
		<dc:creator>DevilWAH</dc:creator>
		<pubDate>Tue, 10 Jan 2012 15:22:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.devilwah.com/?p=957#comment-237</guid>
		<description>OK My logic would go some thing like this, can&#039;t put this in to code right now.  

Expected array 

teststring(1) = &quot;switch port access Vlan 10&quot; 
teststring(2) = &quot;switchport mode access&quot;
...
...

then I would break my out put from show run in to separate chunks

intconfig = &quot;&quot; &#039; set varible to null 
if instr(line(x), &quot;interface&quot;)) then  &#039;interface marks start of code block

do
intconfig = intconfig &amp; &quot;,&quot; &amp; line(x)
x=x+1 &#039; increment to next line

while line(x) &lt;&gt; &quot;interface or end of file

arrayintconfig = split(intconfig, &quot;,&quot;)

So you now have an array containing only that interface config.  

so now you can search this string, using each of the expected strings from your array

for x = 0 to ubound(arrayintconfig)
for y = 0 to ubound (teststring) 
if teststring(y) = arrayintconfig(x) then 

matched = matched &amp; &quot;,&quot; y  &#039; this will build up the matched variable with a string containing all the test strings that have been matched, that you can use to work out &#039;what missing later 

else 

next &#039; this test will have told you if the output string from the device has matched any of the test strings. 
next&#039; this will end the loop of the arrayintconfig lines so you have now tested each line against each test line

you will now have a matched string some thing like &quot;1,3,4,5,7&quot; so you would know 0,2,6 are missing and can output test(0),test(2) and test(6) as missing after you have written out the content of arrayintconfig. 

then each time you increment x you need to clear the arrayintconfig, intconfig and matched. 

Does that make any sence? 

1. break apart you output in to a temp array for each indivual interface. 
2. test each of your expected lines against each of the lines from this temp array
3. mark any you find, in a new array/string
4. by a process elimination you can now see what lines are missing.</description>
		<content:encoded><![CDATA[<p>OK My logic would go some thing like this, can&#8217;t put this in to code right now.  </p>
<p>Expected array </p>
<p>teststring(1) = &#8220;switch port access Vlan 10&#8243;<br />
teststring(2) = &#8220;switchport mode access&#8221;<br />
&#8230;<br />
&#8230;</p>
<p>then I would break my out put from show run in to separate chunks</p>
<p>intconfig = &#8220;&#8221; &#8216; set varible to null<br />
if instr(line(x), &#8220;interface&#8221;)) then  &#8216;interface marks start of code block</p>
<p>do<br />
intconfig = intconfig &#038; &#8220;,&#8221; &#038; line(x)<br />
x=x+1 &#8216; increment to next line</p>
<p>while line(x) <> &#8220;interface or end of file</p>
<p>arrayintconfig = split(intconfig, &#8220;,&#8221;)</p>
<p>So you now have an array containing only that interface config.  </p>
<p>so now you can search this string, using each of the expected strings from your array</p>
<p>for x = 0 to ubound(arrayintconfig)<br />
for y = 0 to ubound (teststring)<br />
if teststring(y) = arrayintconfig(x) then </p>
<p>matched = matched &#038; &#8220;,&#8221; y  &#8216; this will build up the matched variable with a string containing all the test strings that have been matched, that you can use to work out &#8216;what missing later </p>
<p>else </p>
<p>next &#8216; this test will have told you if the output string from the device has matched any of the test strings.<br />
next&#8217; this will end the loop of the arrayintconfig lines so you have now tested each line against each test line</p>
<p>you will now have a matched string some thing like &#8220;1,3,4,5,7&#8243; so you would know 0,2,6 are missing and can output test(0),test(2) and test(6) as missing after you have written out the content of arrayintconfig. </p>
<p>then each time you increment x you need to clear the arrayintconfig, intconfig and matched. </p>
<p>Does that make any sence? </p>
<p>1. break apart you output in to a temp array for each indivual interface.<br />
2. test each of your expected lines against each of the lines from this temp array<br />
3. mark any you find, in a new array/string<br />
4. by a process elimination you can now see what lines are missing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on VB again by Manny</title>
		<link>http://www.devilwah.com/2011/05/vb-again/#comment-232</link>
		<dc:creator>Manny</dc:creator>
		<pubDate>Tue, 10 Jan 2012 04:43:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.devilwah.com/?p=957#comment-232</guid>
		<description>Sorry :-) One should be int g0/23 and the other g0/24</description>
		<content:encoded><![CDATA[<p>Sorry <img src='http://www.devilwah.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  One should be int g0/23 and the other g0/24</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on VB again by Manny</title>
		<link>http://www.devilwah.com/2011/05/vb-again/#comment-230</link>
		<dc:creator>Manny</dc:creator>
		<pubDate>Tue, 10 Jan 2012 04:40:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.devilwah.com/?p=957#comment-230</guid>
		<description>Thanks for the link.

Maybe you can help me out.  I have a switch that I need to run a &#039;sh run &#124; section (^interface_[FG][a-z].+) to only list interfaces that begine with interface and are of Gigabit or Fastethernet flavor.

The idea is to check every instance of  &#039;FastEthernet or GigabitEthernet&#039; and ensure that certain configuration has been made below each interface (e.g. ip access-group %whatever the ACL is% )

interface FastEthernet1/0/1
 switchport
 switchport access vlan 120
 switchport mode access
 switchport voice vlan 220
 no shutdown
 snmp trap mac-notification change added
 snmp trap mac-notification change removed
 snmp trap link-status
 auto qos voip trust 
 spanning-tree portfast


I would then compare the output of each sh run to a list of expected lines (seen above) if it finds the command under the interface, write it out to a file.
I am currently capturing the output of the &#039;sh run&#039; into an array:

crt.Screen.Send &quot;sh run &#124; section (^interface_[FG][a-z].+)&quot; &amp; vbcr
crt.Screen.WaitForString vbcr
strResultsDSL = crt.Screen.ReadString(&quot;#&quot;)

&#039; Create array of expected lines to compare to the output from the Cisco device.
Dim vExpectedDSL(3)
vExpectedDSL(0) = &quot; switchport mode access&quot;
vExpectedDSL(1) = &quot;switchport access vlan 120&quot;
vExpectedDSL(2) = &quot; switchport voice vlan 210&quot;

nCount = 0
vConfigLines = Split(strResultsDSL, vbcr)

For nOuterIndex = 0 To UBound(vExpectedDSL) - 1
    For nInnerIndex = 0 To Ubound(vConfigLines) - 1
        If InStr(vConfigLines(nInnerIndex), vExpectedDSL(nOuterIndex)) Then
            &#039; Write to file vExpectedDSL(nOuterIndex) to file with a YES
            &#039; MsgBox     &quot;Found: &quot; &amp; vbcrlf &amp; vbtab &amp; vExpectedDSL(nOuterIndex)
			objStream.Write vExpectedDSL(nOuterIndex) &amp; &quot;,YES&quot; &amp;vbcrlf
            Exit For
        Else
            If Ubound(vConfigLines) - 1 = nCount Then
                &#039; Write to file vExpectedDSL(nOuterIndex) to file with a NO
                &#039; MsgBox     &quot;Not Found: &quot; &amp; vbcrlf &amp; vbtab &amp; vExpectedDSL(nOuterIndex)
				objStream.Write vExpectedDSL(nOuterIndex) &amp; &quot;,NO&quot; &amp;vbcrlf
				nCount = 0
			Exit For
            End If
        End If
    nCount = nCount + 1
    Next
Next

What is your suggestion to looping through the config until it cannot find anymore F/Gethernet ports?

The output should just be :

Interface G0/1/23
 switchport mode access, YES &#039; if it matched it to the expected lines 
 switchport access vlan 120, NO &#039; If it did not match it
Interface G0/1/23
 switchport mode access, YES &#039; if it matched it to the expected lines 
 switchport access vlan 120, NO &#039; If it did not match it

Or something like, 
Interface G0/1/23 &quot;missing:&quot;
 switchport access vlan 120

But not write anything if it is OK.

Any help would greatly be appreciated.</description>
		<content:encoded><![CDATA[<p>Thanks for the link.</p>
<p>Maybe you can help me out.  I have a switch that I need to run a &#8216;sh run | section (^interface_[FG][a-z].+) to only list interfaces that begine with interface and are of Gigabit or Fastethernet flavor.</p>
<p>The idea is to check every instance of  &#8216;FastEthernet or GigabitEthernet&#8217; and ensure that certain configuration has been made below each interface (e.g. ip access-group %whatever the ACL is% )</p>
<p>interface FastEthernet1/0/1<br />
 switchport<br />
 switchport access vlan 120<br />
 switchport mode access<br />
 switchport voice vlan 220<br />
 no shutdown<br />
 snmp trap mac-notification change added<br />
 snmp trap mac-notification change removed<br />
 snmp trap link-status<br />
 auto qos voip trust<br />
 spanning-tree portfast</p>
<p>I would then compare the output of each sh run to a list of expected lines (seen above) if it finds the command under the interface, write it out to a file.<br />
I am currently capturing the output of the &#8216;sh run&#8217; into an array:</p>
<p>crt.Screen.Send &#8220;sh run | section (^interface_[FG][a-z].+)&#8221; &amp; vbcr<br />
crt.Screen.WaitForString vbcr<br />
strResultsDSL = crt.Screen.ReadString(&#8220;#&#8221;)</p>
<p>&#8216; Create array of expected lines to compare to the output from the Cisco device.<br />
Dim vExpectedDSL(3)<br />
vExpectedDSL(0) = &#8221; switchport mode access&#8221;<br />
vExpectedDSL(1) = &#8220;switchport access vlan 120&#8243;<br />
vExpectedDSL(2) = &#8221; switchport voice vlan 210&#8243;</p>
<p>nCount = 0<br />
vConfigLines = Split(strResultsDSL, vbcr)</p>
<p>For nOuterIndex = 0 To UBound(vExpectedDSL) &#8211; 1<br />
    For nInnerIndex = 0 To Ubound(vConfigLines) &#8211; 1<br />
        If InStr(vConfigLines(nInnerIndex), vExpectedDSL(nOuterIndex)) Then<br />
            &#8216; Write to file vExpectedDSL(nOuterIndex) to file with a YES<br />
            &#8216; MsgBox     &#8220;Found: &#8221; &amp; vbcrlf &amp; vbtab &amp; vExpectedDSL(nOuterIndex)<br />
			objStream.Write vExpectedDSL(nOuterIndex) &amp; &#8220;,YES&#8221; &amp;vbcrlf<br />
            Exit For<br />
        Else<br />
            If Ubound(vConfigLines) &#8211; 1 = nCount Then<br />
                &#8216; Write to file vExpectedDSL(nOuterIndex) to file with a NO<br />
                &#8216; MsgBox     &#8220;Not Found: &#8221; &amp; vbcrlf &amp; vbtab &amp; vExpectedDSL(nOuterIndex)<br />
				objStream.Write vExpectedDSL(nOuterIndex) &amp; &#8220;,NO&#8221; &amp;vbcrlf<br />
				nCount = 0<br />
			Exit For<br />
            End If<br />
        End If<br />
    nCount = nCount + 1<br />
    Next<br />
Next</p>
<p>What is your suggestion to looping through the config until it cannot find anymore F/Gethernet ports?</p>
<p>The output should just be :</p>
<p>Interface G0/1/23<br />
 switchport mode access, YES &#8216; if it matched it to the expected lines<br />
 switchport access vlan 120, NO &#8216; If it did not match it<br />
Interface G0/1/23<br />
 switchport mode access, YES &#8216; if it matched it to the expected lines<br />
 switchport access vlan 120, NO &#8216; If it did not match it</p>
<p>Or something like,<br />
Interface G0/1/23 &#8220;missing:&#8221;<br />
 switchport access vlan 120</p>
<p>But not write anything if it is OK.</p>
<p>Any help would greatly be appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on VB again by test</title>
		<link>http://www.devilwah.com/2011/05/vb-again/#comment-225</link>
		<dc:creator>test</dc:creator>
		<pubDate>Fri, 30 Dec 2011 14:01:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.devilwah.com/?p=957#comment-225</guid>
		<description>testing</description>
		<content:encoded><![CDATA[<p>testing</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on VB again by DevilWAH</title>
		<link>http://www.devilwah.com/2011/05/vb-again/#comment-224</link>
		<dc:creator>DevilWAH</dc:creator>
		<pubDate>Fri, 30 Dec 2011 13:07:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.devilwah.com/?p=957#comment-224</guid>
		<description>Hi, 

If you look at my confgen tool in the link above this is a c# application that uses config saved in text files as the master templates. 

If you want to do the same with secure crt you can use a file open dialogue to get the user to chose a template file when they run the script. 

then simple read it in to an array and use it use it as you have in your current script with the hard coded config you are currently using. 

This link below will give you some ideas how to get a file name and path from the user, 

http://www.robvanderwoude.com/vbstech_ui_fileopen.php

you can then simple read in each line of the file in turn using objStream to an array. 

Hope that helps if you need more info I can give you some code snipits to look at. 

Regards 

DevilWAH</description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>If you look at my confgen tool in the link above this is a c# application that uses config saved in text files as the master templates. </p>
<p>If you want to do the same with secure crt you can use a file open dialogue to get the user to chose a template file when they run the script. </p>
<p>then simple read it in to an array and use it use it as you have in your current script with the hard coded config you are currently using. </p>
<p>This link below will give you some ideas how to get a file name and path from the user, </p>
<p><a href="http://www.robvanderwoude.com/vbstech_ui_fileopen.php" rel="nofollow">http://www.robvanderwoude.com/vbstech_ui_fileopen.php</a></p>
<p>you can then simple read in each line of the file in turn using objStream to an array. </p>
<p>Hope that helps if you need more info I can give you some code snipits to look at. </p>
<p>Regards </p>
<p>DevilWAH</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on VB again by Manny</title>
		<link>http://www.devilwah.com/2011/05/vb-again/#comment-223</link>
		<dc:creator>Manny</dc:creator>
		<pubDate>Fri, 30 Dec 2011 05:26:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.devilwah.com/?p=957#comment-223</guid>
		<description>Good day,  

I too am working on a similar script using SCRT.  What I am doing is writing a script for a customer that want to compare his &#039;running-configs&#039; with a &#039;standard config&#039;.  I have been able to do this with arrays, IF/THEN, the objStream to write to a file.  However it is not portable in the sense that the script itself has the lines of code I am comparing to.  It would be nicer to read a file, run a &#039;sho run all&#039; read that output and then compare.  I am writing &#039;if the line is found %the-line&amp; &amp; &quot;,Y&quot;.  This way the customer could easily change his standard config and the script still work.

The output is comma separated (only 2 columns) 

If you have anything like that, please share.  If not, when I finally get mine cleaned up, I will send it your way.

cheers</description>
		<content:encoded><![CDATA[<p>Good day,  </p>
<p>I too am working on a similar script using SCRT.  What I am doing is writing a script for a customer that want to compare his &#8216;running-configs&#8217; with a &#8216;standard config&#8217;.  I have been able to do this with arrays, IF/THEN, the objStream to write to a file.  However it is not portable in the sense that the script itself has the lines of code I am comparing to.  It would be nicer to read a file, run a &#8216;sho run all&#8217; read that output and then compare.  I am writing &#8216;if the line is found %the-line&amp; &amp; &#8220;,Y&#8221;.  This way the customer could easily change his standard config and the script still work.</p>
<p>The output is comma separated (only 2 columns) </p>
<p>If you have anything like that, please share.  If not, when I finally get mine cleaned up, I will send it your way.</p>
<p>cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Upgrading Redundant Supervisors on 6500&#8242;s by DevilWAH</title>
		<link>http://www.devilwah.com/2010/10/upgrading-redundant-supervisors-on-6500s/#comment-215</link>
		<dc:creator>DevilWAH</dc:creator>
		<pubDate>Sat, 17 Dec 2011 23:22:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.devilwah.com/?p=893#comment-215</guid>
		<description>yes as long as the boot statments point to the correct place and you have the correct image on the correct Sups it will be the same. 

IOS does not care where it is booting from as long as the path it correct and is available at boot.</description>
		<content:encoded><![CDATA[<p>yes as long as the boot statments point to the correct place and you have the correct image on the correct Sups it will be the same. </p>
<p>IOS does not care where it is booting from as long as the path it correct and is available at boot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Upgrading Redundant Supervisors on 6500&#8242;s by Luke</title>
		<link>http://www.devilwah.com/2010/10/upgrading-redundant-supervisors-on-6500s/#comment-213</link>
		<dc:creator>Luke</dc:creator>
		<pubDate>Fri, 16 Dec 2011 18:21:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.devilwah.com/?p=893#comment-213</guid>
		<description>Will the process be the same if your sups don&#039;t have compact flash cards so you upload your new image to sup-bootdisk and slavesup-bootdisk and change each command and configuration accordingly?</description>
		<content:encoded><![CDATA[<p>Will the process be the same if your sups don&#8217;t have compact flash cards so you upload your new image to sup-bootdisk and slavesup-bootdisk and change each command and configuration accordingly?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching using disk: basic
Object Caching 447/449 objects using disk: basic

Served from: www.devilwah.com @ 2012-02-23 06:18:32 -->
