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 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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 commands...one 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 ...how 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:

Code:
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:

file1.tcl
file.tcl
filex.tcl
file2.tcl


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 http://expect.nist.gov.  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 www.opentalk.org.uk 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., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho