Modify A Program

hi all,

I'm sorry for my english.

I have this problem:
I and my collegues can modify the same file at the same time.
Is it possible delete this problem?

The editor is VI.

thanks.

Good Morning,

this is not a problem, this is a feature :slight_smile:

No, of course you can edit the same file X times at the same time, but when you are not the first one, who edit this file, you will usually get a message, that a temporary file exists.
So you have to accept it and go on with modification, bad idea, or you you have to leave.

Maybe it's a better idea to work locally on your own file, and after editing, you sync your file with the original file, look at cvs for example, its very powerfull.

regards
Alex

Hi,

a solition might be ci/co, standard on HP-ux and Sun (and maybe more). It's a horrible apllication but it keeps you from these problems.

Of course you can write a script that does, the folowing ? :

#!/usr/local/bin/perl
# Script that creates lock-file

$file=$ARGV[0];
@last_f=split(/\//, $file );
@last_f=reverse @last_f;
$last_f = $last_f[0];

if ( -f "/tmp/${last_f}" ) {
print "Sorry, $last_f is still opened by someone else \n";
}
else {
`touch /tmp/${last_f}`;
$cmd = sprintf("/usr/bin/vi %s",$file);
$status = system($cmd);
`rm /tmp/$last_f`;
}

Regs David

just make sure not to run that script as root....someone could put a symbolic link where that /tmp lockfile is to point to /etc/nologin, or worse yet /dev/kmem. etc, etc.

i think mandatory locking would do what you want...
that forbid multi-access to one file...

chmod +l <file>

read the man page for better explanation...

greetings Pre�y