Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simultaneous processes with TCL

Status
Not open for further replies.

JRyanCon

Technical User
Aug 19, 2004
47
US
How would I go about executing a process and then continuing down the script. For example.


proc step_one{} {
copy file C:\file.txt D:\file.txt
}

proc step_two{} {
execute new command
}


step_one (Now I want this to be going on in the background...and move on down the script)

step_two

then I would want to wait for step_one to finish then loop starting at step_one.

Is this possible and if so what would this be called. having a hard time looking up information since I am not sure what I would call this.

thanks,
 
What platform and are you using tcl threads?
 
on
It says:

In this release, the Tcl language itself provides no support for creating multithreaded scripts (for example, scripts that could spawn a Tcl interpreter in a separate thread). If you need to add this feature at this time, see the tclThreadTest.c file in the Tcl source distribution for an experimental implementation of a Tcl "Thread" package implementing thread creation and management commands at the script level.


Hmmm So I take it I would have to get the source and recompile it in Windows to get this support? Have you seen or heard of anyone using this? Unfortunately this is under windows so the Fork() isnt posible. Basically I want to do this:

set i "0"

copy file file$i.txt to destination
run md5 check on file.txt while copy file file$i.txt to destination

and loop this. ( of course incr i 1 after each download ). It kinda seems like I am stuck and this isnt really possible in TCL with out some experimental packages or something?

Any thoughts?
 
Right. Your problem looks ideally suited to having
a concurrent thread do the md5 calculation and
then return the result to some global data structure.

OTOH, and I was thinking of this earlier, there is
bgexec available with the BLT package that lets you
approximate what you want.
See here:
 
Thanks for the input however looking into that BLT package I find this:

========================
BLT 2.1 patch for Tcl/tk 8.0a1 Patch 2
This patch incorporates the following:
blt.h is now C++ friendly.
Bug fixes in "graph/barchart postscript cget" option.
( Eric H. Herrin, II <eric@hsdi.com> ): Barchart bugfix in PrintActiveBar and DrawActiveVar.
( Carl Roth, <roth@cse.ucsc.edu> ): bgexec fix to work with tk4.2 and later. Still doesn't work for me.
Font fixes needed for tk8.0.
Use tclInt.h and tkInt.h to import Tcl internal structures instead of copying these (and hence avoid breaking every release).
*NEW* Fix bltTable.c (ParseRowCol) so as not to mess with incoming argv. This fixes a problem in Patch 1, which caused table to misbehave. Thanks for Brian Lewis of Sun for pointing out the problem.

Things that DON'T work
Htext looks horrible. I doubt if I'll ever fix it.
Bgexec doesn't work. <(============ * * * * ** *
All the demos seem to work, but this is probably quite unstable as it stands, so play at your own risk.

========================

so I am not sure hmmmm....seems I might be stuck here.
 
Can you do something like this?

Code:
set pone [open "|scriptname" r]
fileevent $pone readable [list handleEvent $pone]

Async I/O and a separate script is my last suggestion..

 
Figured I should update this post to tell what I did to get around my issue. I Used Perl :) it has "threads" which will allow you to run multiple procs at once. If anyone has this same issue you might cheack out Perl forum and title of "Win32::process Question". I actually ended up using Threads not Win32::process, but anyways I thought I should close this issue out.

Thanks for the help marsd. Just seemed Perl had an easier answer to this issue.
 
You need to recompile Tcl with thread extension.
then use TclThreads.


 
I'm kicking myself on this one.
Check out twapi:

This is the coolest extension for windows I've seen and
gives you almost all the flexibility of the unix tcl env
in windows. Of course you stillhave to learn the 'windows
way' of doing things but it's not a huge learning curve to implement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top