0

There are two or more scripts.
Script A

#Script A
setenv K1 V1

Script B

#Script B
source "script A"
# some code

When I run script B from its location its work fine.
But I need to run it from some other location like:
_> /some/other/location/ # tclsh pathtoscriptB/script.tcl

It giving error
couldn't read file "script A": no such file or directory.

Note : Location of script can be changed according to user who use it.

8
  • Did you try something like source "$pathtoscriptA/script.tcl"? Commented Dec 11, 2017 at 9:39
  • We do not know at which path user store these scripts. We only know that both script are at same location .. Commented Dec 11, 2017 at 9:42
  • Then what about the path to scriptB? Commented Dec 11, 2017 at 9:53
  • lets Suppose Script stored at A/B/C/scriptB.tcl <br> But we may run it from path A/D/E/ Commented Dec 11, 2017 at 9:54
  • Then scriptA will be in the same location according to your previous comment, right? Commented Dec 11, 2017 at 9:56

1 Answer 1

3

Try the technique given at the end of page http://wiki.tcl.tk/1384 - adapted for this case, script B would do:

source [file join [file dirname [info script]] "script A"]
Sign up to request clarification or add additional context in comments.

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.