1

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

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.

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.

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.

1
  • 1
    What does "the response from the shell is that the tcl file embedded in the shell script cannot be found" mean? What exactly is the error message? Do you have a proper #! line at the top of each script? Commented Oct 21, 2011 at 8:10

2 Answers 2

1

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…

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

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

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

package require Tcl 8.5

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

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


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

Sign up to request clarification or add additional context in comments.

1 Comment

Finally, it was an internal bash script error of mine, while changing directories using relative paths ... But, however, thank you very much for your response and your help.
0

Could the problem be as simple as the fact that you don't have "." in your PATH? What if instead of calling your script like "myscript.tcl" you call it like "./myscript.tcl" or "/absolute/path/to/myscript.tcl"?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.