The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
test for function name? duderonomy UNIX for Advanced & Expert Users 5 05-14-2008 03:52 AM
C function to test existence of a login xavier054 High Level Programming 2 03-04-2008 09:51 AM
Telnet script to test open ports on mult servers liketheshell Shell Programming and Scripting 2 02-14-2008 08:13 PM
Help needed to test CorneliOS open source software on different platforms joskirps UNIX for Advanced & Expert Users 0 06-20-2007 12:39 PM
C function to test string or integer qqq High Level Programming 3 03-09-2005 09:55 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-09-2006
Registered User
 

Join Date: Feb 2006
Posts: 7
function to test if file is open

I need to write a function that will work in sh/ksh shell that will test to see if a file has already been opened for writting by another user

has anyone written something like this?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-09-2006
Registered User
 

Join Date: Feb 2006
Posts: 7
by the way - i don't have execute permissions on fuser and lsof not on system
Reply With Quote
  #3 (permalink)  
Old 03-10-2006
Registered User
 

Join Date: Feb 2006
Posts: 7
i think you can also do it using the "test -t" but can't seem to figure out the syntax - has anyone done this?
Reply With Quote
  #4 (permalink)  
Old 03-10-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,355
test -t is used to test if a file descriptor is pointing to a tty device:

if [ -t 0 ] ; then
echo this will go to a tty
fi

It is one of the few things that a double bracket test cannot do. fuser and lsof are the only programs that can do this. If you don't have lsof, get it. Or live without the capability.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0