0

I am trying to run test.tcl file from main.tcl file , without sourcing it and I am getting error saying no file or directory even though both script in same directory.

  main.tcl script content: 
  tclsh test.tcl
  exec "C:\\Tcl\bin|\test.tcl"
  tclsh test.tcl

  test.tcl script content: 
  puts "Executed Second script" 

I tried both exec command and tclsh commands and its not working. Could you please suggest some idea to handle it.

1 Answer 1

2

Leave test.tcl the same as it is. Change main.tcl as follows. It assumes that test.tcl and main.tcl are in the same folder. If you do use full or relative paths, note that when using \folder\subdir, you need to double-slash \\folder\\subdir, or just use single forward-slash (Tcl has *nix origins) /folder/subdir.

puts "From main.tcl launching test.tcl"
set result  [exec [info nameofexecutable] test.tcl]
puts $result

From the command line type:

tclsh.exe main.tcl

And the result will look like this:

From main.tcl launching test.tcl
Executed Second script
Sign up to request clarification or add additional context in comments.

2 Comments

might want to use set result [exec [info nameofexecutable] test.tcl] instead of hardcoding "tclsh.exe"
Thank you. I will check and get back to you .

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.