test if file is open
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > test if file is open




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    test if file is open  
James


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-10-05 11:03 PM

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






[ Post a follow-up to this message ]



    Re: test if file is open  
Janis Papanagnou


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-10-05 11: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





[ Post a follow-up to this message ]



    Re: test if file is open  
RolandRB


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-11-05 12:49 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

Use

/usr/sbin/fuser -u






[ Post a follow-up to this message ]



    Re: test if file is open  
RolandRB


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-11-05 12:49 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

Use

/usr/sbin/fuser -u






[ Post a follow-up to this message ]



    Re: test if file is open  
RolandRB


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-11-05 12:49 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

Use

/usr/sbin/fuser -u






[ Post a follow-up to this message ]



    re:test if file is open  
johnsonbryce


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-10-06 10: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?






[ Post a follow-up to this message ]



    Re: test if file is open  
Keith Thompson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-11-06 01:47 AM

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.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:56 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register