Abhinesh
Abhinesh

Reputation: 123

Running tcl Script from other directory while script refer to a local file

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.

Upvotes: 0

Views: 1095

Answers (1)

Colin Macleod
Colin Macleod

Reputation: 4372

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"]

Upvotes: 3

Related Questions