11-22-2006
OK
If you follow the previous instructions and paste the following into a script named vi and situate it in the /usr/bin directory. I have tested it with no errors.
#!/bin/ksh
#
vimod=/usr/bin/viedit
#
# The above is the renamed vi executable.
#
vercnt=/tmp/vercnt
vercnt1=/tmp/vercnt1
#
# You can put the above anywhere you want.
#
PID=$$
#
# Check the number of attribs equal to zero no file name given.
#
if [[ $# -eq 0 ]]
then
echo No file name given exiting
exit 3
fi
#
vifile=$1
grep $vifile $vercnt 1>/dev/null 2>&1
if [[ $? != 0 ]]
then
echo $vifile":$PID" >> $vercnt
else
echo Sorry this file is already being edited please try later
exit 3
fi
#
# This is where vi will be called.
#
$vimod $vifile
#
# When the vi session ends the function will return here and delete the PID entry from the
# holding file.
#
cat $vercnt | grep -v $PID > $vercnt1
mv $vercnt1 $vercnt
Enjoy.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
We have a ksh which runs once every 15 minutes. Based on a certain condition (for invalid data) we are spooling a file and if the file is of length greater than 0 bytes, then we are mailing this file to a group of users. Upon receiving the file, users correct the data so that on its next run the... (2 Replies)
Discussion started by: Sree_2503
2 Replies
2. AIX
:confused:We've had close to 100 calls about users logging into our AIX server. The users open up about 3 to 5 sessions in the server. After 2hrs of idle time, users are frozen or stuck in the IBM UniVerse Application. We (system administrators) have been blaming the application (which we'll take... (2 Replies)
Discussion started by: Sarccastik Dude
2 Replies
3. Solaris
I would like to know how to prevent users connecting to a server using SSH as root.
I would still like them to be able to login with their username and then change to su.
But I would like to prevent them logging in directly as root.
I have searched the forum and read that I should set... (3 Replies)
Discussion started by: Sepia
3 Replies
4. Solaris
hello,
I have a challenge to find a way to lock down a file in a user's home directory, such that a user can NOT modify, rename, move, delete, etc. The solution needs to be deployable without, for example, having to switch from unix to windows, etc
We are using NFS. We want to lock the... (1 Reply)
Discussion started by: jvmagic
1 Replies
5. UNIX for Advanced & Expert Users
I have a samba server which is serving a mixture of files. One main application uses a data file and creates a temporary working execution file at startup and holds that temp execution file open for the duration of the program's execution (but doesn't use the file at all after initial startup).
... (0 Replies)
Discussion started by: humbletech99
0 Replies
6. UNIX for Dummies Questions & Answers
I am working on a project where I need to make many changes to files, both inside and outside of the vi editor. I make small changes manually right in vi, and I have a script that I run from another session that I use to make bigger changes to the files using sed.
After running my script from... (2 Replies)
Discussion started by: RickS
2 Replies
7. HP-UX
We have an old (11.11) HP-UX system. A couple of months ago, our customers started having problems with their logins.
After sitting idle for roughly an hour, their screens would lock up and they would be kicked out of the system. This happens if they are in the application or on the command... (2 Replies)
Discussion started by: slkdnichols
2 Replies
8. Shell Programming and Scripting
Hello Team,
I want to know if there is any one liner command , using which I can edit multiple column of a file.
input file input.txt (comma separated),
taran, 12.45, uttam, 23.40, babay
karan, 12.45, raju, 11.40, rahulg
I want to update, 2nd and 4th column,
but want all those column... (8 Replies)
Discussion started by: Uttam Maji
8 Replies
9. AIX
Hi
The telnet sessions stay as idle users. It is not getting kicked out.
Please advise what could be the issue. only when we reboot the server these telnet sessions goes.
Below is the current output from the server. we rebooted the server three days ago:
pmut6:/> uptime
04:21PM... (8 Replies)
Discussion started by: newtoaixos
8 Replies
10. UNIX for Beginners Questions & Answers
Hi - If iam logged on to server A, on 4 putty windows using SSH ... and out of these 4 logged-in sessions, in one of the sessions if i did SSH from server A to server B;
i would now have 4 putty windows sessions ... of which 3 are actively logged on to Server A while 1 putty window is actively... (2 Replies)
Discussion started by: i4ismail
2 Replies
LEARN ABOUT PHP
cli_set_process_title
CLI_SET_PROCESS_TITLE(3) 1 CLI_SET_PROCESS_TITLE(3)
cli_set_process_title - Sets the process title
SYNOPSIS
bool cli_set_process_title (string $title)
DESCRIPTION
Sets the process title visible in tools such as top and ps. This function is available only in CLI mode.
PARAMETERS
o $title
- The new title.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
ERRORS
/EXCEPTIONS
An E_WARNING will be generated if the operating system is unsupported.
EXAMPLES
Example #1
cli_set_process_title(3) example
<?php
$title = "My Amazing PHP Script";
$pid = getmypid(); // you can use this to see your process title in ps
if (!cli_set_process_title($title)) {
echo "Unable to set process title for PID $pid...
";
exit(1);
} else {
echo "The process title '$title' for PID $pid has been set for your process!
";
sleep(5);
}
?>
SEE ALSO
cli_get_process_title(3), setproctitle(3).
PHP Documentation Group CLI_SET_PROCESS_TITLE(3)