在Tcl/Tk脚本中执行Shell命令
set n 0
set x "*"
while {$n < 10} {
puts $x
set x "$x"*
set n [expr $n + 1]
}
在Tcl/Tk脚本中调用Shell脚本
shell脚本
#!/usr/bin/bash
# test.sh
n=0
x="*"
while [ $n -lt 10 ]
do
echo "x"
x=$x*
n=`expr $n + 1`
done
Tcl/Tk脚本
demo.tcl
#!/usr/bin/tclsh
set ret [exec bash test.sh]
puts $ret
命令行输入
tclsh demo.tcl