A script to tell which workstations are using Samba shares
Posted by: Anonymous
[ip: unknown]
on October 03, 2007 04:42 PM
You could pipe the output of the lsof command directly into the while loop running as a subprocess. That would cut out the need for the temporary file.
A script to tell which workstations are using Samba shares
Posted by: Anonymous [ip: unknown] on October 03, 2007 04:42 PMEg.
echo "PCs USING THE APPLICATION:"
lsof | grep /usr/apps/payroll | gawk '{ print $2 }' | uniq | {
while read row ; do
grep `netstat -p | grep $row | gawk '{ print $5 }' | cut -d":" -f1` /etc/hosts
if [ $? -ne 0 ]; then
netstat -p | grep $row | gawk '{ print $5 }' | cut -d":" -f1
end if
done }
#