从tcl脚本调用bash脚本并返回并退出状态

tga*_*gai 6 bash tcl

我试图从TCL脚本调用bash脚本,并需要从bash脚本获取退出状态,或者至少将某些内容传回TCL脚本,以便我可以判断我的脚本是否成功执行.有什么建议?

gle*_*man 10

请参阅http://wiki.tcl.tk/exec - 单击"显示讨论"按钮 - 这是一个非常详细的示例,说明如何完全按照您的要求进行操作.你需要的是什么catch

set status [catch {exec script.bash} output]

if {$status == 0} {
    puts "script exited normally (exit status 0) and wrote nothing to stderr"
} elseif {$::errorCode eq "NONE"} {
    puts "script exited normally (exit status 0) but wrote something to stderr which is in $output"
} elseif {[lindex $::errorCode 0] eq "CHILDSTATUS"} {
    puts "script exited with status [lindex $::errorCode end]."
} else ...
Run Code Online (Sandbox Code Playgroud)