我是TCL的新手.如何在Windows和Linux上运行通用的tcl脚本?我想首先检查平台类型,然后调用适当的tcl proc.
您可以从查看tcl_platform数组开始.在我的(Windows)机器上,报告以下内容:
% parray tcl_platform
tcl_platform(byteOrder) = littleEndian
tcl_platform(machine) = intel
tcl_platform(os) = Windows NT
tcl_platform(osVersion) = 5.1
tcl_platform(platform) = windows
tcl_platform(threaded) = 1
tcl_platform(tip,268) = 1
tcl_platform(tip,280) = 1
tcl_platform(user) = username
tcl_platform(wordSize) = 4
Run Code Online (Sandbox Code Playgroud)
在Unix系统中的操作系统和OSVERSION将是报告的值uname -s
和uname -r
respectivley.如果您需要更复杂的东西,那么平台包可能就是您要走的路!
小智 7
是的,杰克逊.基本上,我想知道我的脚本运行的操作系统,例如,
set OS [lindex $tcl_platform(os) 0]
if { $OS == "Windows" } {
perform this ...
} else {
perform that ...
}
Run Code Online (Sandbox Code Playgroud)