
tcl 脚本
iteye_7333
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
tcl 小技巧
1,expr 【expr arg ?arg ...?】可以有一个或者多个参数a,expr增加花括号,运行的效率更高。【这个与Tcl内部所使用的字节码编译器有关】例子:expr {1/3}结果:0b,注意保留小数。例子:expr {1/3.0}结果:0.333333333333c,表达式中可以使用括号。例子:expr {(2+3)*4}结果:20d,花括号内部还可以使用变量例子:set a ...原创 2010-07-24 16:48:52 · 269 阅读 · 0 评论 -
tcl regexp
regexp regexp {(?:.*)(?:xx/)(.*?)(/)(.*)} $b all var=============== tst ===============set a {<xxxxx/fadxx/abc/yyyyyyyyyyyyyyy }if [regexp {(?:.*)(?:ip/)(.*?)(/)(.*)} $b all var] {puts $va...原创 2014-03-26 16:42:27 · 609 阅读 · 0 评论 -
tclsh中的事件支持没有tkcon中好
【关键字】 tclsh tkcon socket fileevent1,在学习socket 的时候,发现在tkcon中正常运行的程序,在tclsh中不能正常运行后来发现,一些回调函数在tclsh中不能够正确的运行如,socekt -server callback,这里的callback不能够执行,还有针对于socket的注册的一些fileevent不能够很好的执行。2,解决在注册事件后,v...原创 2011-05-13 20:56:04 · 357 阅读 · 0 评论 -
查找字符串出现的次数
【关键字】tcl 查找 字符串 重复 次数tcl中没有直接查找字符串出现次数的命令,不过可以用regsub来代替。set lines [regsub -all \n $reply {} junk]lines 就是reply 中出现 \n的次数,也可以将lines 理解为reply 是多少行。...原创 2011-05-13 19:11:18 · 1483 阅读 · 0 评论 -
tcl中exec找到的java和javac不是同一个版本
关键字:tcl exec auto_execok env 1, java找到了1.5的,javac找到了1.6的。真是奇怪,帮助中说,exec和cmd中不同,cmd中找到的是同一个版本。2,auto_execok 可以看到找到的exec运行的外部命令的全路径;3,在cmd的中可以“start java”运行看java的全路径。4,另外,exec在tk中运行,tk的stdin、s...原创 2011-05-04 22:12:50 · 164 阅读 · 0 评论 -
tcl format
【关键字】tcl format 格式化输出用法 format formatString ?arg arg ...?可以指定数据的类型,可以指定小数点的位数,对齐的方式,数值的宽度。eg,【format "Today I buy %4d apple, the price is %6.2f." 125 2.33333】Today I buy 125 apple, the price ...原创 2011-04-12 14:58:06 · 4416 阅读 · 0 评论 -
tcl [string map] 替换字符串 很是方便
【关键字】:Tcl string map 替换字符串 写道string map ?-nocase? mapping string Replaces substrings in string based on the key-value pairs in mapping. mapping is a list of key value key value ... as in the for...原创 2011-04-12 14:42:35 · 8504 阅读 · 0 评论 -
tcl中查看系统的信息
【关键字】tcl 系统信息 tcl命令 写道foreach {key value} [array get tcl_platform] {puts "key: $key \tvalue: $value"} 结果 写道key: osVersion value: 5.1 key: byteOrder value: littleEndian key: threaded val...原创 2011-04-11 16:05:24 · 836 阅读 · 0 评论 -
tcl 中的exec运行第三方,怎么同时打印第三方信息到stdout
运行第三方程序: exec ?switches? arg ?arg ...? 同时打印出信息到stdout呢?exec ?switches? arg ?arg ...? >@ stdout 这个方法还试验的不少次数,没有发现,因为tkcon中不支持这种,奇怪了。tclsh中就支持。 当然,也可以用open |some program得到pipe...2011-09-22 13:43:11 · 1308 阅读 · 0 评论 -
tcl 中的exec运行第三方,怎么同时打印第三方信息到stdout 。版本2
假的长时间运行的程序:proc long_job {} {puts "long_job start"puts "- after 1s start"after 1000puts "- after 1s start"after 1000puts "- after 1s start"after 1000puts "- after 1s start"after 1...原创 2013-04-17 19:09:26 · 467 阅读 · 0 评论