无法从bash shell脚本执行Tcl脚本 [英] Tcl script cannot be executed from bash shell script

查看:158
本文介绍了无法从bash shell脚本执行Tcl脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对从shell脚本中调用的bash shell脚本和tcl脚本有一个相对陌生的问题.

I have a relatively strange problem with bash shell scripts and tcl scripts, invoked from within the shell scripts.

从角度来看,我有一个Shell脚本,它可以生成其他一些Shell脚本以及tcl脚本.一些生成的shell脚本使用tclsh命令调用tcl脚本.这些文件被创建并存储在一个目录中,该目录也由初始的Shell脚本创建,该目录会生成文件和要存储这些文件的文件夹.

In perspective, I have a shell script that generates some other shell scripts, as well as tcl scripts. Some of the generated shell scripts invoke tcl scripts with tclsh command. The files are created and stored in a directory, also created by the initial shell scripts, that generates the files and the folders where these are to be stored.

问题在于生成的shell脚本,该脚本调用tclsh来运行tcl脚本.即使生成了文件并且shell脚本具有要执行的权限,shell的响应仍然是找不到嵌入在shell脚本中的tcl文件.

The problem is with the generated shell scripts, which invoke tclsh to run a tcl script. Even if the files are generated and the shell scripts have the permissions to be executed, the response from the shell is that the tcl file embedded in the shell script cannot be found.

但是,该文件存在,我可以使用vi和gedit,RHEL 9.0或Centos 5.7平台打开它.但是,当我从创建的目录中取出相同的Shell脚本时,不会出现此错误.你能提出任何建议吗?我也检查了目录权限,但是看起来还可以.我还检查了shell脚本中是否有多余的字符,但没有找到任何内容.

However, the file exists and I can open it with both vi and gedit, RHEL 9.0 or Centos 5.7 platforms. But, when I take the same shell script out of the created directory, this error does not appear. Can you please suggest any idea? I checked also directory permissions, but they seem ok. I also checked the shell script for extra characters, but I did not find anything.

推荐答案

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

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.)

这篇关于无法从bash shell脚本执行Tcl脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆