Modify A Program


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Modify A Program
# 1  
Old 07-25-2003
Data 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.
# 2  
Old 07-25-2003
modify problem

Good Morning,

this is not a problem, this is a feature Smilie

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
# 3  
Old 07-25-2003
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
# 4  
Old 08-17-2003
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.
# 5  
Old 08-18-2003
.......

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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl program get a response before the program quits

I created a program, so a kid can practice there math on it. It dispenses varies math problems and the kid must input an answer. I also want it to grade the work they have done, but I can't find the best place for it to print out the grade. I have: if ( $response =~ m/^/ ) { $user_wants_to_quit... (1 Reply)
Discussion started by: germany1517
1 Replies

2. Shell Programming and Scripting

modify awk

awk "BEGIN {if($PERCENT<$WARNING) {print \"OK\" ; exit 0} else if(($PERCENT>=$WARNING) && ($PERCENT<$CRITICAL)) {print \"WARNING\" ; exit 1} else if($PERCENT>=$CRITICAL) {print \"CRITICAL\" ; exit 2} }" how can i... (1 Reply)
Discussion started by: SkySmart
1 Replies

3. Shell Programming and Scripting

Modify file

Hi, I have a file that looks like this: 27+:<10,289808,1> 31+:<11,1445372,1> 33-:<7,1014101,2> 35+:<11,728811,1> 36-:<11,1445205,0> 37+:<11,1445792,2> and I want to change it to this: + 10 289808 + 11 1445372 - 7 1014101 + 11 728811 - 11 1445205 + 11 1445792 (3 Replies)
Discussion started by: kylle345
3 Replies

4. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

5. Programming

Python program faster than C++ program.

I wrote a simple program that generates a random word 10,000,000 times. I wrote it in python, then in C++ and compared the two completion times. The python script was faster! Is that normal? Why would the python script be faster? I was under the impression that C++ was faster. What are some of... (2 Replies)
Discussion started by: cbreiny
2 Replies

6. Shell Programming and Scripting

about the modify lines

Hello, I am trying to convert lines from text file, I got lines in text files like that ALPHA.cab tomtom.cab vgame.cab converter.cabWhat i want to do is I want to conver these lines like that, cabwiz.exe ALPHA.cab extract "C:\1extract\ALPHA" cabwiz.exe tomtom.cab extract ... (5 Replies)
Discussion started by: davidkhan
5 Replies

7. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

8. Programming

A program to trace execution of another program

Hi, I wanted to know if i can write a program using switches and signals, etc to trace execution of other unix program which calls c program internally. If yes how? If not with signals and switches then are there any other methods apart from debugging with gdb/dbx. (3 Replies)
Discussion started by: jiten_hegde
3 Replies

9. Shell Programming and Scripting

modify and use awk sed program

The following awk script creates a file b.dat. awk '{print substr($0,1,27),substr($2,index($2,"_")+1)," ",substr($0,49)}' a.dat > b.dat I need this script to be modified to also sum $3 values by distinct $1 and $2 fields. Current file W2_2009275 2 8 W2_2009275 2 7 W1_2009275 1... (3 Replies)
Discussion started by: mnnarendra
3 Replies

10. Shell Programming and Scripting

modify a file

I'm a new member of the forum, I had this new generate file since I use 'grep' and 'awk', what I want to do is get rid off the all 0s before the numbers, is there any one who could help me to figure it out? Thanks a lot! yun 0000000029 000q7472 2002/03/01 0000000030 000q7472 2002/03/01 ... (2 Replies)
Discussion started by: yxiao
2 Replies
Login or Register to Ask a Question