Novell Home

Find Out Who Has a Specific File Open on OES Linux

Novell Cool Solutions: Tip
By Olaf Zerfowski

Digg This - Slashdot This

Posted: 28 Apr 2006
 

PROBLEM:

Find the user who has a specific file open on OES Linux

Sometimes it is helpful to see who has a specific file open (for updates etc). In NetWare you can go into Monitor - File open/lock activity - go to the file - and see who has it open. Also the NetWare Remote Manager can easily show who has this file open.

In OES Linux there is no easy way (i am aware of) to do the same. You can use Remote Manager - View File System - and see information about the file, but not who has the file open.

The Manage NCP Services -> Manage Connections -> choose a connection will show you the open files of this specific connection. But - if you have many connections on a server it could be very hard to find the User that has your file open.

SOLUTION:

It's possible to gain such data from the server command line.

ncpcon from the OES Linux command line can show you information about connections and open files.

  • "ncpcon connection" gives you an overview.
  • "ncpcon connection 7" shows the same as you can see in Remote Manager / Manage Connections for connection 7. But you still have the problem that you have to choose every connection to find your file.

A little shell script can do this work for you.

Lets call it "openfile" and chmod 755 it.

You can call openfile without parameters - then you see all connections that have a file open on every NSS Volume (/media/NSS/) on your OES Linux Server.

"./openfile /media/NSS/VOL1" will give you all Connections that have files open on /media/NSS/VOL1.

And finally "./openfile /media/NSS/VOL1/Directory/important.xls" gives you all users that have this specific file open.

EXAMPLE:

#/bin/bash
# description: List open files on OES
# author:      Olaf Zerfowski
# version:     0.01
# date:        04-20-2006

maxcon=`ncpcon connection 2>/dev/nul| sed -ne  "s/.*Connection Slots Allocated\t//pg"`

count=0

if [ "$1" == "" ]
then
searchstring=/media/nss/
else
searchstring=$1
fi

echo "Max Connections=$maxcon"
echo "SearchString=$searchstring"

while  [ $count -lt $maxcon ]
do
conninfo=`ncpcon connections $count 2>nul| egrep "Name|$searchstring"`
if echo $conninfo | grep "$searchstring" 1>/dev/nul 2>&1
then
       echo Connection $count
       ncpcon connections $count 2>nul| egrep "Name|$searchstring"
fi
count=`expr $count + 1`
done

ENVIRONMENT:

Tested on OES Linux SP2

I am a Linux NewBee - so any suggestion for improvement is welcome ;-)


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell