🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
` `在tcl脚本中调用shell的脚本,如下: ``` #!/usr/bin/tclsh #在tcl脚本中调用bash脚本 puts "" puts "××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××" puts "运行在tcl脚本中调用bash脚本,对应脚本为 example/useBashIntcl.tcl" puts "××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××" puts "下面将会调用 syahello.sh输出hello,bash!到shelllog文件" exec bash sayhello.sh ;#使用exec调用shall脚本 puts "调用操作成功" puts "" ``` ``` #!/bin/bash echo "hello,bash"\>shelllog ``` 再看一个例子 test.sh ```bash shell脚本 #!/usr/bin/bash # test.sh n=0 x="*" while [ $n -lt 10 ] do echo "x" x=$x* n=`expr $n + 1` done ``` demo.tcl ```tcl Tcl/Tk脚本 demo.tcl #!/usr/bin/tclsh set ret [exec bash test.sh] puts $ret ``` 执行`tclsh demo.tcl` ![](https://img.kancloud.cn/dd/35/dd357b4ff04bf7df62ed5221087b237d_162x220.png)