kccole
asked on
File Locking for editing ??
Hello,
I'm running on a Sun SPARCstation 5 (SunOS 5.5.1) can
someone please tell me the best way to control this situation: There are several files that several people need to change concurrently (using vi and emacs). These 3 people
are members of a unique unix group. How can we ensure that
we are not editing the same file at the same time? This is not source code and we don't want to use SCCS or any other
source control system - We're looking for some file locking
mechanism; e.g., John is ready to edit file "foo.doc" he
executes <unix.file.locking.command > he then edits the document; after finished with edits he unlocks the file <unix.file.locking.command -u>.
Thanks !
kcc
I'm running on a Sun SPARCstation 5 (SunOS 5.5.1) can
someone please tell me the best way to control this situation: There are several files that several people need to change concurrently (using vi and emacs). These 3 people
are members of a unique unix group. How can we ensure that
we are not editing the same file at the same time? This is not source code and we don't want to use SCCS or any other
source control system - We're looking for some file locking
mechanism; e.g., John is ready to edit file "foo.doc" he
executes <unix.file.locking.command
Thanks !
kcc
ASKER
Thanx for your reply but unfortunately I'm left with too many questions as to what each line of code does exactly and how it can be used in the example I supplied (in other words please
make it more idiot proof! with comments for code and an explanation of how to implement/execute when needing to edit the
file.
Thanx Much!
kcc
make it more idiot proof! with comments for code and an explanation of how to implement/execute when needing to edit the
file.
Thanx Much!
kcc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
alias vi to vi-lock (for example)
shell script for vi-lock (not security proofed):
#! /bin/sh
file=$1
chmod g-w $file
chmod o-w $file
/bin/vi $file
chmod g+w $file
chmod o+w $file
shell script for vi-lock (not security proofed):
#! /bin/sh
file=$1
chmod g-w $file
chmod o-w $file
/bin/vi $file
chmod g+w $file
chmod o+w $file
ASKER
ahoffman,
Doesn't your script work only if the owner of the file isn't
a possible editor of the file ? e.g.,
unix id=sammi group id=sammi
Sammi decides to add 3 other user's (unix id's) to his group:
group sammi ==> sammi, franki, noel, pransor
If franki executes your script and edits a common file
having the permission of 775 (before executing it) then
what will prevent Sammi from editing the same file at the same
time, thus corrupting the changes franki has made?
thanx!
kcc
Doesn't your script work only if the owner of the file isn't
a possible editor of the file ? e.g.,
unix id=sammi group id=sammi
Sammi decides to add 3 other user's (unix id's) to his group:
group sammi ==> sammi, franki, noel, pransor
If franki executes your script and edits a common file
having the permission of 775 (before executing it) then
what will prevent Sammi from editing the same file at the same
time, thus corrupting the changes franki has made?
thanx!
kcc
ASKER
Adjusted points to 75
ASKER
Hello All,
I've just learned of a utility called "led" on my system
that allows the very thing I need to do. I just thought I'd poll the readers to see if anyone else knew of its existence too and
if so why do home grown stuff when something is already there to
use??
Thanx Again.,
kcc
I've just learned of a utility called "led" on my system
that allows the very thing I need to do. I just thought I'd poll the readers to see if anyone else knew of its existence too and
if so why do home grown stuff when something is already there to
use??
Thanx Again.,
kcc
never heard of it.. Are you sure it's not a local thing? (It's not
on any of our Solaris2 boxes)
on any of our Solaris2 boxes)
ltemp="$NEWSCTL/L.$$"
echo $$ >$ltemp
trap "rm -f $ltemp ; exit 0" 0 1 2 15
while true
do
if ln $ltemp $lock
then
trap "rm -f $ltemp $lock ; exit 0" 0 1 2 15
break
fi
sleep 30
done