A script to tell which workstations are using Samba shares

A combination of Linux utilities can help you determine who on your network is using which of your shared filesystems at any given time, allowing you to ask those users to log off while you update the system.

For more details:
http://www.linux.com/feature/119470

Code:

lsof | grep /usr/apps/payroll | gawk ‘{ print $2 }’ | uniq > tmp
echo “PCs USING THE APPLICATION:”
while read row ; do
   netstat -p | grep $row | gawk ‘{ print $5 }’ | cut -d”:” -f1
done < tmp

Output:

./script.sh
PCs USING THE APPLICATION
192.168.100.32
192.168.100.78

2 thoughts on “A script to tell which workstations are using Samba shares

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s