Hi,
I need to match a particular pattern in the output of ifconfig command which i have written a code in tcl to match.I am getting an error near if condition and unable to proceed further.. Please help me in solving the same
#!/usr/bin/tclsh
set x " Link encap:Ethernet HWaddr 3C
9:2B:09:76:54
inet addr:172.16.51.100 Bcast:172.16.51.127 Mask:255.255.255.128
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:383037553 errors:0 dropped:0 overruns:0 frame:0
TX packets:300897395 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4259153427 (4061.8 Mb) TX bytes:3588769001 (3422.5 Mb)
Interrupt:169 Memory:f4000000-f4012800"
set y [ split $x "\n" ]
puts [lindex $y]
puts [llength $y]
set index [ lindex $y 3]
puts [lindex $y 3]
if {[ regexp {frame} $index ] > 0 }
{
puts "The IP is pinging"
}
{
puts "The IP is not pinging"
Also let me know how can i write a code in TCL if i have a matrix as below
A B C D E
1 2 3 4 5
a b c d e
and if i need to search for the element 5 and if available print the corresponding all elements in the same row of 5.
Thanks in advance.
Kamesh