tcl软件测试工资待遇,tcl exec介绍 - 测试人生 - 51Testing软件测试网 51Testing软件测试网-软件测试人的精神家园...

参见:

Here are some examples of the use of theexeccommand on Unix.

To execute a simple program and get its result:execuname -a

To execute a program that can return a non-zero result, you should wrap the call toexecin-errorcodereturn option if you have an error:set status 0

if {[catch {execgrep foo bar.txt} results options]} {

set details [dict get $options -errorcode]

if {[lindex $details 0] eq "CHILDSTATUS"} {

set status [lindex $details 2]

} else {

# Some kind of unexpected failure

}

}

When translating a command from a Unix shell invocation, care should be taken over the fact that single quote characters have no special significance to Tcl. Thus:awk '{sum += $1} END {print sum}' numbers.list

would be translated into something like:execawk {{sum += $1} END {print sum}} numbers.list

If you are converting invocations involving shell globbing, you should remember that Tcl does not handle globbing or expand things into multiple arguments by default. Instead you should write things like this:execls -l {*}[glob *.tcl]

WINDOWS EXAMPLES

Here are some examples of the use of theexeccommand on Windows.

To start an instance ofnotepadediting a file without waiting for the user to finish editing the file:execnotepad myfile.txt &

To print a text file usingnotepad:execnotepad /p myfile.txt

If a program calls other programs, such as is common with compilers, then you may need to resort to batch files to hide the console windows that sometimes pop up:execcmp.bat somefile.c -o somefile

With the filecmp.batlooking something like:@gcc %1 %2 %3 %4 %5 %6 %7 %8 %9

Sometimes you need to be careful, as different programs may have the same name and be in the path. It can then happen that typing a command at the DOS prompt findsa different programthan the same command run viaexec. This is because of the (documented) differences in behaviour betweenexecand DOS batch files.

When in doubt, use the commandexeccommand. This applies especially when you want to run “internal” commands likedirfrom a Tcl script. (if you just want to list filenames, use theexec{*}[auto_execok dir] *.tcl

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值