I have two tcl scripts. And I want to run second script when first finished. How can I do it?
相关问题
- Printing out source hierarchy with large TCL proje
- TCL Email Script doesn't deliver in Activestat
- tcl: how to use the value of a variable to create
- How to print non-BMP Unicode characters in Tkinter
- TCL string match vs regexps
相关文章
- String Range forward and backward lookaround
- Equivalent of #define in tcl?
- How to compile dll loadable in tcl
- tcl lsearch on list of list
- Can Anyone Explain ?: in regular expression [dupli
- gets not waiting for user input in expect script
- Passing list to Tcl procedure
- How can I assign a variable using $expect_out in T
You just need to use source to run the 2nd script.
While this is generally a correct answer, becouse the question was not precicely formulated there are tons of ways to achive the goal of running tcl code from within tcl. I wan't to get into this in detail, becouse understanding the execution of code is one major point in understanding tcl itselve.
There is source
The source command should not be confound with executing scripts in a classical way, what I think the thread starter has asked.
The source command is like the "include" command in c/perl/php. Languages like java or python on the other hand only have "import" mechanisms.
The difference is that those languages create a internal database of avaliable packages, who are linked to the corresponding source/binary/bytecode files. By writing a import statement, linked source or bytecode or binary files are loaded. This allows more in-depth dependency management without writing additional code. In tcl this can be achived with namespaces and the package require command. Example:
Suppose you have this source.tcl:
Now, you have your "master" script like you call it. I call it "main". It has the content:
The exec command
If you can live with additional overhead of starting a whole new interpreter instance you could also do:
The eval command
Eval can evaluate a string or a list (in tcl everything is a string) like it would be programmed code. You would have to load the complete source file to a string. And then use eval, to evaluate the code within a seperated scope, to not overwrite stuff in your main source file.
Depends on what do you really mean.
One way is to write a third ("master") script which would do
Another way is to just add the second call to
source
from the above example to the bottom of the first script.Amendment to the first approach: if the scripts to be executed are located in the same directory as the master script, an idiomatic way to
source
them isThis way sourcing will work no matter what the current process's directory is and where the project directory is located.