Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Tcl commands execution from two fifferent files

Posted by pgpatel (pgpatel), 26 July 2005
Hi all

I am new in this forum...
i have question regarding tcl...
I want to execute some tcl commands in particular sequence...commands are depend on one another...
For example commands are create ,connect ,get_result,save result etc....
Now i want to make two script file with some file with create and connect...and another file with get_result and save result....
and now i want to execute this two file....
first file i can execute...after that i want to execute something else and then again i want to execute 2nd file can i maintain continuation between 1st and 2nd file? i donot want to execute commands in first file again...
please help me..
thanks in advance....

Posted by admin (Graham Ellis), 26 July 2005
Have a look at the source command that lets you call up one file from within another.

Here's an example - a simple file called t1 calls up the code in a second file called t2 through the source command:

earth-wind-and-fire:~/jul05 grahamellis$ tclsh t1
first file
second file
more in first file
earth-wind-and-fire:~/jul05 grahamellis$ cat t1
puts "first file"
source t2
puts "more in first file"
earth-wind-and-fire:~/jul05 grahamellis$ cat t2
puts "second file"
earth-wind-and-fire:~/jul05 grahamellis$

Posted by pgpatel (pgpatel), 26 July 2005
Thanks for reply...
but i know this thing..
and source command execute all the commands in the file... and i donot want to execute it again....i am clearing the question....

suppose this is my code:


and i want the continuation between file 1 and file 2 without reexecuting commands in file 1...

awaiting for a favourable reply...

Posted by admin (Graham Ellis), 26 July 2005
The source command pauses the execution of the current file and causes the named file to be run before the current file is resumed.  If it's the very last executable statement in a file, in effect it chains two files together.

If you want to execute all the contents of file1 then all the contents of file2, you can either:

add source file2 as an extra line at the end of file1

or create a new file which contains
source file1
source file2

and then run that file as your complete Tcl program.

Posted by pgpatel (pgpatel), 26 July 2005
Thanks for reply again....
But i want to execute those files remotely....
with ssh command line as two differene command....
now please suggest me

Posted by admin (Graham Ellis), 26 July 2005
on 07/26/05 at 20:05:28, pgpatel wrote:
i want to execute those files remotely....
with ssh command line as two differene command....

OK - that's not something that I got from your initial two posts ...

On the brief specification that you've given me, I would probably suggest that you have a look at the Expect extension to Tcl, but there's all sorts of other questions that I would have to ask you to go into more detail of exactly how it would work for you.   Can I suggest that you start off by having a look at (and following links from  You should find tutorials, examples, downloads, articles, etc there ... far too much for me to put into an Opentalk post.

Expect programming isn't always easy, so if you get to the stage of having written some code but you're not able to get it to work exactly as you would wish, please do start another thread up and post a code sample so that we can help.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho