Re: How to control the loop within expect.



Hu Junfeng wrote:
Bruce Hartweg 写道:
...
Thanks, it works:)
But I find another problem with it ,if I put the continue in a
procedure, it will not works again. for example:

Read the man/help page on the return command.

proc CMD {con} {
upvar CMDSUCC CMDSUCC
upvar CMDFAIL CMDFAIL
send -i $con "cd /nodes\r"
expect {
-i $con
$CMDSUCC {
puts "succe"
continue
}
$CMDFAIL {
puts "fail"
continue
}
}
puts "123"
}



set i 0
if {$i==0} {
foreach $i {1 2 3 4 5} {
CMD $CLICom
}
} else {
puts "hehe"
}


the result is invoked "continue" outside of a loop



--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
.



Relevant Pages

  • Re: Dereferencing?
    ... Schelte Bron wrote: ... > Donal K. Fellows wrote: ... >> upvar $v ... >> puts $v ...
    (comp.lang.tcl)
  • Re: TCL equivalent of PHP "phpinfo()"?
    ... > Phil Powell wrote: ... >> of using global and upvar together and it magically works for me so I ... > set foo 1 ... > puts $msg ...
    (comp.lang.tcl)
  • Re: How to get path?
    ... proc cb { ... puts "$a $b" ... foreach bt { ...
    (comp.lang.tcl)
  • Re: Dereferencing?
    ... Donal K. Fellows wrote: ... > the array so you get something like this: ... > puts $v ... just do "upvar 0 $key v" either within or outside a procedure. ...
    (comp.lang.tcl)