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!

How to avoid run a script that is already running?

Status
Not open for further replies.

lucensys

Programmer
Mar 9, 2005
7
US
Hello All,

Does anybody how to do this?
I need to avoid that the same script be executed if a previous session of the same script is alredy running.

Thanks in advance.
 
what OS? That is, it is primarily not a Tcl question although Tcl can handle the answer the OS gives - maybe.

_________________
Bob Rashkin
 
I'm sorry, this is a tcl script running under Windos 2000.
I'd like to know, just for curiosity how to do this enterly with Tcl if it it possible.

regards,

Lucensys
 
I don't think you can, unless you can guarantee that you will be "asking" from within the same Tcl shell (interpreter instance) as the presumptive executing script. That is, say, info will tell you what the current interpreter is dealing with:
info script ?filename?
If a Tcl script file is currently being evaluated (i.e. there is a call to Tcl_EvalFile active or there is an active invocation of the source command), then this command returns the name of the innermost file being processed. If filename is specified, then the return value of this command will be modified for the duration of the active invocation to return that name. This is useful in virtual file system applications. Otherwise the command returns an empty string.

However, if you just run a script and expect to know what other Tcl scripts are running on the same platform, you have to interogate the OS. You can do so from within Tcl using exec but I don't know what the ps -ef analog is for Windows.

_________________
Bob Rashkin
 
Try looking into using pstat, a Microsoft freeware program. Its basically the Windows equivalent to UNIX's ps command
 
Thanks a lot you guys,

You comments help me to find the way to do this.

I found a similar microsoft utility to list all the process running, tList.exe run like a DOS command it works only for win2K, there is another utility for windows XP this is taskList.exe.

thanks again.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top