PDA

View Full Version : checking/queueing access to file in tcl ?


b>d>>s
10-26-2003, 10:33 AM
hi, i started using a sql .dll in itcl for queueing access to the stats log file in a zipscript, but this is slow and mechanical (and now i got a new bug with it :X).

is there some trick to checking the status of a file with another tcl instance of zipscript, ie.

zs_1 has.ioftpd.log 'open' (thus i would read this as 'locked').
zs_2 checks 'status' of .ioftpd.log, if opened by another script ('locked'), queue.
zs_1 'closed' ('unlocked') .ioftpd.log
zs_2 'opens' .ioftpd.log (thus 'locking' it somehow).

?

any help, thx.

Mouton
10-26-2003, 12:16 PM
If you want to lock "testfile", try and create a *new* "testfile.lock" in the same directory. Repeat (with ample sleep) until this succeeds. To unlock, simply remove the file. This method is supported by almost all configurations.

flock might be avail too
http://osr5doc.ca.caldera.com:457/cgi-bin/man/man?flock+TCL

b>d>>s
10-26-2003, 12:46 PM
ok, then to queue ? maybe, after ms ?script script script ...?

in a loop, ? say, ?

while {1} {
after 1000
set a [file exists "c:/blah.log"]
if {0 == $a} {
break
}
}

hmm, that should do it. what about thread safe stuff ?