FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

Instantly share code, notes, and snippets.

Created January 28, 2011 21:44
Show Gist options
  • Select an option

    Clone this repository at <script src="https://gist.github.com/allthingscode/801044.js"></script>
  • Save allthingscode/801044 to your computer and use it in GitHub Desktop.

Select an option

Clone this repository at <script src="https://gist.github.com/allthingscode/801044.js"></script>
Save allthingscode/801044 to your computer and use it in GitHub Desktop.
Sometimes it can be frustrating when you need to delete/rename/move a file via a samba file share, but you can't because it's locked by someone else. This script attempts to look up the IP address of all samba users that are currently using the file. S
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
#!/bin/bash
#
SCRIPT=${0##*/}
if [[ $# -ne 1 ]] ; then
echo "usage: $SCRIPT filename"
exit 192
fi
OUTPUT=`lsof "$1"`
if [[ -z "$OUTPUT" ]] ; then
echo "Nothing is using that file."
exit 0
fi
for PID in `lsof "$1" | awk '/smbd/{print $2}'` ; do
OUTPUT=`grep -Ril $PID /var/log/samba/`
OUTPUT=${OUTPUT##*/}
echo $OUTPUT
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Back | FazBrowse Home | New Git URL