如果不需要返回错误信息,则可以使用catch命令来捕捉错误。 5.使用exit命令:在函数中使用exit命令可以退出tclsh。如果exit命令出现在函数中,则需要通过设置标志变量来让函数正常退出。 总之,在tclsh中,退出函数的方法有很多种,开发者可以根据实际情况选择最合适的方法。
set retval [catch {set f [open "nosuchfile" "r"]}] if {$retval == 1} { puts "An error occured"} Output: (this output occurs if there is no file named "nosuchfile" in the current directory).An error occuredCatch 参数记录一个script的执行情况,如果返回值为1,则执行出错。用来进行错误...
namespace import ::cisco::lib::* if { [catch {cli_open} result] } { error $result $errorInfo } array set cli $result cli_exec $cli(fd) "enable" set output [cli_exec $cli(fd) "ping 192.168.1.1 repeat 1"] puts $output catch {cli_close $cli(fd) $cli(tty_id)} 0 Helpful ...
/usr/bin/tclsh- from package:tcl You may install the required package with commandapt-get install {package} Error in other languages: tclsh: bevel nie gevind nie tclsh: comandă negăsită tclsh: comando não encontrado tclsh: commande introuvable tclsh: command not found tclsh: käsku ...
events happens in the first chapter, “The Things They Carried” and in the chapter “How To Tell a True War Story”, where Curt Lemon was blown up by grenades, “I remember the shadows spreading out under the trees where Curt Lemon and Rat Kiley were playing catch with smoke grenades....