- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl; open a file in vi
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2003 06:38 AM
тАО07-25-2003 06:38 AM
I have an idea of opening a file and creating a lock-file for it.
Creating the lock-file and removing it is no problem. However opening the file is a bigger problem, It doesn't show my input (of course);
Any ideas how I should get the vi work ?
#!/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}`;
`/usr/bin/vi $file`;
`rm /tmp/$last_f`;
}
## I know I am missing quiet some perl-code here that is replace by `shell code`, you are allowed to improve it :) else I will find out myself on the internet.
Regs David
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2003 06:39 AM
тАО07-25-2003 06:39 AM
Re: Perl; open a file in vi
It will lock the file while you have operations on it. Anyone else trying to do operations on the file will fail.
You can even allow reads while you are writing. Or not.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2003 06:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2003 06:45 AM
тАО07-25-2003 06:45 AM
Re: Perl; open a file in vi
Great replacement for mine. My intention however is to make sure our admins always moderate an /etc/hosts file only by one in a time :)
So what I was looking for is a way of opening /etc/host like this :
openfile /etc/hosts
openfile would then be my perl-script instead of vi. Your solution solves the lock of the text file, but not the vi issue. Any ideas how in/ouput gets redirected back to my terminal ?
Regs David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2003 06:49 AM
тАО07-25-2003 06:49 AM
Re: Perl; open a file in vi
Many thanks !!
Regs David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2003 06:50 AM
тАО07-25-2003 06:50 AM