RE: TCL Script help

From: Tyson Scott <tscott_at_ipexpert.com>
Date: Fri, 12 Nov 2010 20:44:17 -0500

Marcin,

It didn't work because the script is wrapped in what you are typing in.
Gotta love email lists at times. I can't attach a text file either on this
list or it will be deleted

So note

proc ping1 {IP} {
 set PING [ exec "ping vrf CUST1 $IP repeat 10" ]
 set PING [ regexp -inline -all {[\.!]{3}} $PING ]
 if { [ string first "!" $PING ] == -1 } {
 puts "[format "%-40s %s" "ping $IP" "****** FAILED *******" ]"
 } else { puts "[format "%-40s %s" "ping $IP" "****** PASSED *******" ]" }
}
proc ping2 {IP} {
 set PING [ exec "ping vrf C-GRATE $IP repeat 10" ]
 set PING [ regexp -inline -all {[\.!]{3}} $PING ]
 if { [ string first "!" $PING ] == -1 } {
 puts "[format "%-40s %s" "ping $IP" "****** FAILED *******" ]"
 } else { puts "[format "%-40s %s" "ping $IP" "****** PASSED *******" ]" }
}

Those are first the process. Let both of them be copied in. Then start the
next part of running the scripts.

foreach address {
10.8.2.1
10.8.2.2
10.8.2.7
10.8.0.45
10.3.1.1
10.3.2.1
10.3.0.26
10.3.0.3
172.16.64.1
172.16.68.1
} { ping2 $address }

foreach address {
167.10.10.5
10.10.0.1
10.10.0.5
} { ping1 $address }

I tested the script myself so I know it works. As a caution to you... it is
typically not a good venture to start running scripts when you don't
understand what they are doing.

It is a good thing I am not someone trying to give you invalid information.

Regards,
 
Tyson Scott - CCIE #13513 R&S, Security, and SP
Managing Partner / Sr. Instructor - IPexpert, Inc.
Mailto: tscott_at_ipexpert.com

-----Original Message-----
From: Marcin Zgola [mailto:MZgola_at_netrixllc.com]
Sent: Friday, November 12, 2010 2:26 PM
To: Marcin Zgola; Senthil Kumar; Tyson Scott; 'Cisco certification'
Subject: RE: TCL Script help

NTX-6509-A01(tcl)#proc ping1 {IP} {
+> set PING [ exec "ping vrf NTXPRIVMPLS $IP repeat 10" ] set PING [ regexp
+>-inline -all {[\.!]{3}} $PING ] if { [ string first "!" $PING ] == -1
+>} { puts "[format "%-40s %s" "ping $IP" "****** FAILED *******" ]"
+> } else { puts "[format "%-40s %s" "ping $IP" "****** PASSED *******"
+>]" } } proc ping2 {IP} { set PING [ exec "ping vrf C-GRATE $IP repeat
+>10" ] set PING [ regexp -inline -all {[\.!]{3}} $PING ] if { [ string
+>first "!" $PING ] == -1 } { puts "[format "%-40s %s" "ping $IP"
+>"****** FAILED *******" ]"
+> } else { puts "[format "%-40s %s" "ping $IP" "****** PASSED *******"
+>]" } } foreach address {
+>10.8.2.1
+>10.8.2.2
+>10.8.2.7
+>10.8.0.45
+>10.3.1.1
+>10.3.2.1
+>10.3.0.26
+>10.3.0.3
+>172.16.64.1
+>172.16.68.1
+>} { ping2 $address }
wrong # args: should be "proc name args body"
NTX-6509-A01(tcl)#foreach address {
+>167.10.10.5
+>10.10.0.1
+>10.10.0.5
+>} { ping1 $address }
invalid command name "ping1" ^
% Invalid input detected at '^' marker.

-----Original Message-----
From: nobody_at_groupstudy.com [mailto:nobody_at_groupstudy.com] On Behalf Of
Marcin Zgola
Sent: Friday, November 12, 2010 11:57 AM
To: Senthil Kumar; Tyson Scott; 'Cisco certification'
Subject: RE: TCL Script help

It did not work.

-----Original Message-----
From: Senthil Kumar [mailto:2008ccie_at_live.com]
Sent: Friday, November 12, 2010 2:38 AM
To: Tyson Scott; Marcin Zgola; 'Cisco certification'
Subject: Re: TCL Script help

Tyson,
Could you please recommend any book for TCL script? I have little
knowledge, and I would like to learn deeper... I appreciate your reply
Thanks

On 12/11/10 3:11 AM, "Tyson Scott" <tscott_at_ipexpert.com> wrote:

>proc ping1 {IP} {
> set PING [ exec "ping vrf CUST1 $IP repeat 10" ]
> set PING [ regexp -inline -all {[\.!]{3}} $PING ]
> if { [ string first "!" $PING ] == -1 } {
> puts "[format "%-40s %s" "ping $IP" "****** FAILED *******" ]"
> } else { puts "[format "%-40s %s" "ping $IP" "****** PASSED *******" ]" }
>}
>proc ping2 {IP} {
> set PING [ exec "ping vrf C-GRATE $IP repeat 10" ]
> set PING [ regexp -inline -all {[\.!]{3}} $PING ]
> if { [ string first "!" $PING ] == -1 } {
> puts "[format "%-40s %s" "ping $IP" "****** FAILED *******" ]"
> } else { puts "[format "%-40s %s" "ping $IP" "****** PASSED *******" ]" }
>}
>foreach address {
>10.8.2.1
>10.8.2.2
>10.8.2.7
>10.8.0.45
>10.3.1.1
>10.3.2.1
>10.3.0.26
>10.3.0.3
>172.16.64.1
>172.16.68.1
>} { ping2 $address }
>foreach address {
>167.10.10.5
>10.10.0.1
>10.10.0.5
>} { ping1 $address }
>
>Regards,
>
>Tyson Scott - CCIE #13513 R&S, Security, and SP
>Managing Partner / Sr. Instructor - IPexpert, Inc.
>Mailto: tscott_at_ipexpert.com
>
>
>-----Original Message-----
>From: nobody_at_groupstudy.com [mailto:nobody_at_groupstudy.com] On Behalf Of
>Marcin Zgola
>Sent: Thursday, November 11, 2010 1:31 AM
>To: Cisco certification
>Subject: TCL Script help
>
>i have a PE router, that i want to develop TCL script that will check
>connectivity to all of the customers.
>
>I am confused with the script. HEre is list of ip addresses i want to ping
>sourcing from each VRF< and results either PASSED or FAILED.
>
>can some one help me?
>
>set cust2 {
>10.8.2.1
>10.8.2.2
>10.8.2.7
>10.8.0.45
>10.3.1.1
>10.3.2.1
>10.3.0.26
>10.3.0.3
>172.16.64.1
>172.16.68.1
>}
>set cust1 {
>167.10.10.5
>10.10.0.1
>10.10.0.5
>}
>foreach address {
>
>} {
>if { [regexp "(!!!!!!!!!)" [exec "ping vrf CUST1 $address rep 10" ]] } {
>puts "$address ****** PASSED *******"
>} else { puts "$address ****** FAILED ******" }
>}
>if { [regexp "(!!!!!!!!!)" [exec "ping vrf C-GRATE $addressgrate rep 10"
>]]
>} {
>puts "$address ****** PASSED *******"
>} else { puts "$address ****** FAILED ******" }
>
>Marcin Zgola
>Internetwork Lead
>CCIE #18676
>Netrix, LLC
>http://www.netrixllc.com
>Ph. 847-964-5300
>Fax.: 847-964-5350
>
>
>Blogs and organic groups at http://www.ccie.net
>
>_______________________________________________________________________
>Subscription information may be found at:
>http://www.groupstudy.com/list/CCIELab.html
>
>
>Blogs and organic groups at http://www.ccie.net
>
>_______________________________________________________________________
>Subscription information may be found at:
>http://www.groupstudy.com/list/CCIELab.html

Blogs and organic groups at http://www.ccie.net
Received on Fri Nov 12 2010 - 20:44:17 ART

This archive was generated by hypermail 2.2.0 : Sun Dec 05 2010 - 22:14:56 ART