Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!topaz!nike!oliveb!intelca!mipos3!mike From: mike@mipos3.UUCP (Michael Bruck) Newsgroups: net.unix-wizards Subject: Re: Open files by users? Message-ID: <160@mipos3.UUCP> Date: Sat, 16-Aug-86 03:13:35 EDT Article-I.D.: mipos3.160 Posted: Sat Aug 16 03:13:35 1986 Date-Received: Sun, 17-Aug-86 10:35:33 EDT References: <157@mipos3.UUCP> Organization: Intel, Santa Clara, CA Lines: 42 Summary: Solution found. I earlier asked: > How can one tell which users have what files open? I essentially need > to see if a particular file is open and by whom. Thanks to everyone on the net who responded. As I found out, on system V, there's a program called fuser which does what I want. Unfortunately, I'm using Ultrix (a.k.a. BSD 4.2~3) so following a suggestion by someone about using pstat -i to get the UID's of all the files open, I came up with the following quick and dirty shell that does the job. It's kind of slow and cumbersome but it saved me from writing a new program and it works well enough for my needs. It's short enough not to bother with net.sources. ------------------------------------------------------------------------- #!/bin/csh set noglob set com = $0 if ($#argv == 0) then echo2 "Usage: $com:t file" exit 1 endif foreach ifile ($argv[*]) if ( ! -f $ifile ) then echo $ifile not found exit 1 endif set inode=`ls -i $ifile` set user=`pstat -i | grep $inode[1] | awk -F, '{print $2}'` if ( "$user" != "" ) then set name=`grep $user[7] /etc/passwd | awk -F: '{print $1}'` echo $name has $ifile open else echo $ifile not open endif end ------------------------------------------------------------------------- --Michael Bruck Intel CAD, Santa Clara, CA {decwrl,hplabs,amdcad}!intelca!mipos3!mike