From: Scott Smith (hioctane@gmail.com)
Date: Tue Oct 11 2005 - 00:08:34 GMT-3
Try this:
proc piall {n} {
foreach ip {
1.1.1.1
2.2.2.2
3.3.3.3
} {
if {[regexp "(!!)" [exec "ping $ip"]]} {
puts "$ip *ok"
} else {
puts "$ip *NOT ok"
}
}
}
On 10/10/05, Victor Cappuccio <cvictor@protokolgroup.com> wrote:
> Hello all,
> what I'm doing wrong in this script?
> Seems that I have to play a little more in TCL
> Thanks
>
> r5#tclsh
> r5(tcl)#proc
> r5(tcl)#proc piall {n} {
> +>(tcl)#192.168.40.4
> +>(tcl)#192.168.10.4
> +>(tcl)#}
>
> r5(tcl)#{
> +>(tcl)#if [regexp "(!!)" ["ping $ip"]]{
> +>(tcl)#puts "$ip *Yeap"
> +>(tcl)#}
> +>(tcl)#else {
> +>(tcl)#puts "Nop $ip"
> +>(tcl)#}
> +>(tcl)#}
> invalid command name "
> if [regexp "(!!)" ["ping $ip"]]{
> puts "$ip *ok"
> }
> else {
> puts "Nop $ip"
> }
> "
>
> if [regexp "(!!)" ["ping $ip"]]{
> puts "$ip *ok"
> }
> else {
> puts "Nop $ip"
> }
>
> ^
> % Invalid input detected at '^' marker.
>
> r5(tcl)#show tcl
> invalid command name "show" ^
> % Invalid input detected at '^' marker.
>
> r5(tcl)#exit
> r5#tcls
> r5#tclsh
> r5(tcl)#pro
> r5(tcl)#proc ping_all {n} {
> +>(tcl)#200.0.0.1
> +>(tcl)#200.0.0.2
> +>(tcl)#200.0.0.4
> +>(tcl)#200.0.0.8
> +>(tcl)#}
>
> r5(tcl)#exec
>
> r5(tcl)#ping_all
> no value given for parameter "n" to "ping_all"
> r5(tcl)#ping_all 1
> invalid command name "200.0.0.1" ^
> % Invalid input detected at '^' marker.
>
> r5(tcl)#
>
> _______________________________________________________________________
> Subscription information may be found at:
> http://www.groupstudy.com/list/CCIELab.html
>
-- Scott Smith
This archive was generated by hypermail 2.1.4 : Sun Nov 06 2005 - 22:00:50 GMT-3