-1

I created a tcl file in a directory and I want to source another tcl file located not in a same directory.

The first file is in the /home/ubuntu/ns/ns-allinone-2.35/ns-2.35, the second one is in the /home/ubuntu/ns/ns-allinone-2.35/ns-2.35/indep-utils/cmu-scen-gen/setdest.

I want to execute :source "home/ubuntu/ns/ns-allinone-2.35/ns-2.35/indep-utils/cmu-scen-gen/setdest/mob.tcl".

As soon as I do this, I get the following error: couldn't read file "home/ubuntu/ns/ns-allinone-2.35/ns-2.35/indep-utils/cmu-scen-gen/setdest/mob.tcl": no such file or directory while executing "source.orig home/ubuntu/ns/ns-allinone-2.35/ns-2.35/indep-utils/cmu-scen-gen/setdest/mob.tcl" ("uplevel" body line 1)

Sergei Danielian
  • 4,938
  • 4
  • 36
  • 58
  • 1
    I see a link at: https://stackoverflow.com/questions/9275098/how-to-run-tcl-script-in-other-tcl-script. One more, I see your code, it seems missing the root /. It can be [:source "/home/ubuntu/ns/ns-allinone-2.35/ns-2.35/indep-utils/cmu-scen-gen/setdest/mob.tcl"] – Vinh Can Code Jul 29 '18 at 05:20
  • One old question [about source](https://stackoverflow.com/questions/6508453/a-question-about-source-in-tcl), may be help you. – L. Alejandro M. Jul 29 '18 at 05:28
  • thanks @VinhCC . I added the root / and it executed correctly. – Somayeh Razaghi Jul 29 '18 at 16:52
  • 1
    Possible duplicate of [How to run tcl script in other tcl script?](https://stackoverflow.com/questions/9275098/how-to-run-tcl-script-in-other-tcl-script) – Jerry Jul 30 '18 at 06:50
  • If answered, why not provide an actual answer and accept it? – mrcalvin Jul 30 '18 at 08:59

1 Answers1

0

I use :source "/home/ubuntu/ns/ns-allinone-2.35/ns-2.35/indep-utils/cmu-scen-gen/setdest/mob.tcl"
and it executed correctly.

  • The usual suggestion is to make a copy of `mob.tcl` to the folder with the simulation, and simply use this line in the simulation : `source "./mob.tcl"` – Knud Larsen Jul 31 '18 at 21:15