我是TCL的新手。我如何在Windows和Linux上运行一个通用的tcl脚本?我想先查看平台类型,然后调用适当的tcl proc。在Windows和Linux上运行常见的TCL脚本
2
A
回答
5
您可以从查看tcl_platform数组开始。在我的(窗口)机本报告如下:
% 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
在Unix系统中的操作系统和OSVERSION将是uname -s
和uname -r
respectivley报告的值。如果你需要更复杂的东西,那么平台包可能是一条可行的路!
6
是的工作,杰克逊。基本上,我想知道我的OS脚本运行上,例如,
set OS [lindex $tcl_platform(os) 0]
if { $OS == "Windows" } {
perform this ...
} else {
perform that ...
}
+4
通常只需检查'$ tcl_platform(platform)'就足够了,因为最新版本的Windows足够类似于大多数Unix,并且足够接近。 – 2010-07-16 23:15:51
3
大多数事情Tcl的工作在Windows和Unix一样的;绝大多数细节都存在差异。为了处理其余部分:
- 使用
file join
,而不是在两者之间/
串联。 - 使用
file nativename
来创建文件名以切换到子进程。 - 请注意
load
;它所做的并不是随身携带的。 info
命令有一些有用的东西,比如Tcl解释器的名字(info nameofexecutable
),所以你可以在子进程中轻松简单地启动解释器。- 有些东西只是不可移植的(例如,访问Windows注册表)。
也有一些细微的差别,但是您必须指导我们如何处理您的程序,以便我们知道什么是重要的(例如,Windows锁定可执行文件在运行时Unix不会;有时会改变事物)。
相关问题
- 1. Eggdrop TCL正常运行时间脚本
- 2. 在apache上运行python脚本(linux和windows)
- 3. 如何在其他tcl脚本中运行tcl脚本?
- 4. 在联网的Linux机器上运行linux脚本的windows上的GUI?
- 5. 执行TCL(expect脚本)在Windows
- 6. 在adb shell上运行linux bash脚本
- 7. 詹金斯Groovy脚本在Windows上运行,但不是Linux
- 8. 如何从Windows服务在Linux上运行脚本?
- 9. 在Windows和Linux上运行C++程序
- 10. Windows上的Ubuntu上的bash Linux,文件夹识别和运行Python脚本
- 11. 命令在Ubuntu中运行Perl脚本中的Tcl(expect)脚本
- 12. 在Windows XP上运行Python CGI脚本
- 13. 在Windows上运行Python脚本(Tkinter)
- 14. 在Windows XP上运行Python CGI脚本
- 15. 在Windows上运行python脚本Ipi rpi
- 16. 在Windows上运行perl脚本
- 17. 如何在Windows上运行SQL脚本?
- 18. 我有困难运行Tcl脚本
- 19. Php:从Windows运行ssh登录到Linux并运行脚本
- 20. 无法通过tcl脚本运行相同的tcl代码?
- 21. 脚本在Windows上运行,但不能在Linux上(语法错误)
- 22. Linux,Mac和Windows上的常见文件系统属性
- 23. 在Windows和Mac上运行的编写脚本
- 24. 运行在Linux的启动脚本
- 25. 从另一个python脚本在Windows上运行Python脚本7
- 26. 如何使用PyScripter从Windows远程调试在Linux上运行的Python脚本?
- 27. 如何在Ubuntu,Windows和MAC上运行Python脚本
- 28. 如何在Windows和Unix上运行npm sh脚本
- 29. 为什么Python脚本可以在Windows上运行,而不是在Linux上运行?
- 30. 在启动时运行Linux脚本
tcl已经与平台无关。所以这个问题很难解释。你可以说得更详细点吗?为什么要检查平台类型?你在问“平台”软件包吗? http://tmml.sourceforge.net/doc/tcl/platform.html – 2010-07-16 02:22:35