且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法从bash shell脚本执行Tcl脚本

更新时间:2023-01-31 20:12:06

很难从您的描述中分辨出出了什么问题.您忽略了准确诊断问题所需的所有实际信息.但是...

It's hard to tell what exactly is going wrong from your description; you leave out all the information actually required to diagnose the problem precisely. However…

您的PATH上有一个 tclsh ,但是您的脚本尽管被更改为可执行文件却没有运行?这意味着您的#!行存在问题.当前的***做法是使用类似以下的内容:

You have a tclsh on your PATH, but your script isn't running despite being chmodded to be executable? That means that there's a problem with your #! line. Current best practice is that you use something like this:

#!/usr/bin/env tclsh

这将在您的PATH中搜索tclsh并使用它,并且比任何其他方式都容易得多.

That will search your PATH for tclsh and use that, and it's so much easier than any of the alternative contortions.

可能引起问题的另一件事是,如果您的Tcl程序包含:

The other thing that might be causing a problem is if your Tcl program contains:

package require Tcl 8.5

但是路径上的 tclsh 使用的Tcl版本是8.4.我已经看过很多次了,如果这是您的问题,则需要确保已安装正确的Tcl rpm ,以将您的#!行更新为此:

And yet the version of Tcl used by the tclsh on the path is 8.4. I've seen this a number of times, and if that's your problem you need to make sure that the right Tcl rpm is installed and to update your #! line to this:

#!/usr/bin/env tclsh8.5

与Tcl 8.6类似,但是在这种情况下,您可能也需要从源代码构建自己的代码并将其安装在合适的位置.(Tcl 8.6仍然仅适用于专业人士.)

Similarly for Tcl 8.6, but in that case you might need to build your own from source as well and install that in a suitable location. (Tcl 8.6 is still only really for people who are specialists.)

(问题是RHEL和追踪RHEL的Centos在Tcl方面也非常保守.其原因与这个答案并不完全相关.)

(The issue is that RHEL — and Centos too, which tracks RHEL — is very conservative when it comes to Tcl. The reasons for this aren't really germane to this answer though.)