| Author |
test if file is open
|
|
|
| Is there a way to test in a bourne/bash shell script
whether a file is opened by other programs?
If not, a C program may help also.
Thanks in advance.
James
| |
| Janis Papanagnou 2005-11-10, 6:03 pm |
| James wrote:
> Is there a way to test in a bourne/bash shell script
> whether a file is opened by other programs?
>
> If not, a C program may help also.
>
> Thanks in advance.
> James
>
man lsof
Janis
| |
| RolandRB 2005-11-11, 7:49 am |
|
James wrote:
> Is there a way to test in a bourne/bash shell script
> whether a file is opened by other programs?
>
> If not, a C program may help also.
>
> Thanks in advance.
> James
Use
/usr/sbin/fuser -u
| |
| RolandRB 2005-11-11, 7:49 am |
|
James wrote:
> Is there a way to test in a bourne/bash shell script
> whether a file is opened by other programs?
>
> If not, a C program may help also.
>
> Thanks in advance.
> James
Use
/usr/sbin/fuser -u
| |
| RolandRB 2005-11-11, 7:49 am |
|
James wrote:
> Is there a way to test in a bourne/bash shell script
> whether a file is opened by other programs?
>
> If not, a C program may help also.
>
> Thanks in advance.
> James
Use
/usr/sbin/fuser -u
| |
| johnsonbryce 2006-03-10, 5:57 pm |
| 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 writing by another
user, but i don't have execute permissions on fuser and lsof not on
system
i think you can also do it using the "test
-t" but can't seem to figure out the syntax - has
anyone done this?
| |
| Keith Thompson 2006-03-10, 8:47 pm |
| bryce.johnson@ingenix-dot-com.no-spam.invalid (johnsonbryce) writes:
> 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 writing by another
> user, but i don't have execute permissions on fuser and lsof not on
> system
>
> i think you can also do it using the "test
> -t" but can't seem to figure out the syntax - has
> anyone done this?
No, "test -t" does something different (it tests whether a given file
descriptor (not named file) is opened on a terminal).
If you don't have permissions to run fuser or lsof, you probably can't
do this (if I'm mistaken, I'm sure someone will say so). This is
information about other users that the system deliberately doesn't let
you have. It's possible to install the fuser command SUID root (if
you have root access already), but doing so might open security holes.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
|
|
|
|