Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 11:18 on June 26, 2006


Consult a document on the use of shells to achieve a state of control

Consult dx :
I do not know very much about shell programming, and would like to ask our experts. .
Since many of us are using vi editing documents on the server, in order to ensure version control, and a similar need to use cvs version control tools, I would like to use a shell to control if a document has been in a state of the editors, other people will not open the document and suggested that wishes to open this document plots users Thank you give help

Consult a document on the use of shells to achieve a state of control

[code]
Gabriel /bin/sh
Filename= ""
Tfile= ""
Tpath= ""
Tallfile= ""
Tswpfile= ""
Ch= ""
Vipid= ""
Psstr= ""
EXECVI=/usr/bin/vi
If test $# -eq 0
Then
$EXECVI
Exit
Fi

For filename in $
Do
I=`expr $i + 1`
If one test $i -gt
Then
Clear
Echo "\n\n\n\n\n"
Echo "\t\t whether to continue editing a document Y/N (default Y) \n"
Read ch
If test "x$ch" = "xN" -o "x$ch" = "xn"
Then
Echo "\t\t worship !\n"
Break;
Fi
Fi

Tfile=`basename $filename`
Tpath=`echo $filename|sed-e "s/$tfile//g" `
Tswpfile= "$tpath.$tfile.swp"
Tallfile=`ls $tswpfile.* 2>/dev/null`

If test "x$tallfile"> "x"
Then
Vipid=`echo $tallfile | sed - e 's/.*\.//' `
Psstr=`ps -ef |grep-V grep | grep $vipid`
If test "x$psstr" = "x"
Then
Rm $tallfile
Else
EXECVI=/usr/bin/vi R
Clear
Echo "\n\n\n\n\n"
Echo "has been in \t\t $filename! edit documents will be read-only open \n"
EXECVI=/usr/bin/view
Read ch
Fi
Fi

Tswpfile= "$tpath.$tfile.swp.$$"
"$tswpfile
$EXECVI $filename
EXECVI=/usr/bin/vi
Rm-f $tswpfile

Done
[/code]

If someone in the editing of documents, CD-way will be open.
Aix5, sco5 test.

Consult a document on the use of shells to achieve a state of control

I use the aix5.o version, I shell not know very much about, what the operating procedures force it is not going into the environment variables, please tell us in detail about their usage, the next grateful : :

Consult a document on the use of shells to achieve a state of control

Copy to the above code into a script, for example $HOME/bin/vim

Then, alias vi= 'vim thalamotomy'

Consult a document on the use of shells to achieve a state of control

Wow really, ah, pfpf, study. . . . . .

Consult a document on the use of shells to achieve a state of control

I have done the experiment; ) Without the network environment : (My idea is this :
1, first wrote a script, Vim name :
[code]
If lsof /path|grep q + d $ $ 1;then # If the documents are being edited, it shows that the message from
Echo "$ 1 is editing"
Exit
Else # Otherwise, the $ 1 edit documents
$ Vim thalamotomy
Fi
[/code]
2, and the replacement of the original alias vi
[code]
Vi= alias' sh Vim '
[/code]
3 test : -->

Consult a document on the use of shells to achieve a state of control

! ! ! !

Consult a document on the use of shells to achieve a state of control

Consult a document on the use of shells to achieve a state of control

-->
Ha ha. Good for the country.

Consult a document on the use of shells to achieve a state of control

-->

Fire brothers, not all screen test?, :)

Consult a document on the use of shells to achieve a state of control

NIU! ! ! !

Consult a document on the use of shells to achieve a state of control

Really good, what is the Eastern lsof, can I use the manual lsof like a vegetable, thank em14 : :

Consult a document on the use of shells to achieve a state of control

Lsof the main purpose of the document is information that has been opened
A commonly used in the agreement to open the documents show, for example :
TCP lsof -i
Lsof -i:80
More lsof, read lsof 's manual; )

Consult a document on the use of shells to achieve a state of control

Besides the need to install UNIX

Consult a document on the use of shells to achieve a state of control

Consult a document on the use of shells to achieve a state of control

Vipid=`echo $tallfile | sed - e 's/.*\.//' `
Behind it is to talk about landlord-do not really understand

Consult a document on the use of shells to achieve a state of control

Regard. Deleted before the arbitrary character

Consult a document on the use of shells to achieve a state of control

Regard. Deleted before the arbitrary character



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com