http://www.sun.com/bigadmin/scripts/submittedScripts/get_open_files.ksh.txt
#!/bin/ksh
###
### Pass in a mounted filesystem or a file and get the users
### and processes attached to that system.
###
### Demonstrates the use of 'fuser' and 'ps'.
###
### Arguments:
###
###
###
### Formed from shell-me submittal
### Submitted by: Eric Steed
###
### Check we have 2 args
if [[ $# -lt 2 ]]; then
print "\n Usage: get_open_files
exit 1;
fi
### Set the args to vars
type_of_check=${1}
item_to_check=${2}
### Test the types and do the correct command
if [[ "$type_of_check" = "file" || "$type_of_check" = "dir" ]]; then
/bin/ps -fp `fuser $item_to_check 2> /dev/null| xargs | sed 's/ / -p /g'`
elif [[ "$type_of_check" = "filesystem" ]]; then
/bin/ps -fp `fuser -c $item_to_check 2> /dev/null| xargs | sed 's/ / -p /g'`
else
print "Invalid argument: ${type_of_check} \n"
exit 1
fi
### Exit
exit 0;
No comments:
Post a Comment