summaryrefslogtreecommitdiff
path: root/bin/smbfind
blob: 7bc9ee6f40a6bdab6e758e966cdf86fe813df84b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
#
# export PATH=$PATH:/dos/extras/bin
#
# A replacement for standard perl findsmb.
#
# First get list of ip addresses
#
IPS=`nmblookup \* |awk '{print $1}'|grep -v "Send"`
echo
echo "IP Address      Name       Description"
echo "*************************************"
echo
for i in $IPS
do
  # For each ip address that responds lookup name
  value=`echo $i|awk '{print $1}'`
  MACHINE=`nmblookup -T -A $value |grep "<00>"|awk '{h=tolower($1); print h}'|head -n1`
  TYPE=`smbclient -N -L $MACHINE -I $value 2>&1 |grep "Domain="|head -n1|sed 's/ /_/g'`

  echo "$value $MACHINE $TYPE"
done