This is particularly nasty if you try mounting a share as a user with no password. Smbclient hangs waiting for a password on stdin, for me this locked up X completely.
Here is a patch for 1. and 2. I have also enabled three extra icons that show when smbclient is still scanning, there are no shares to mount, the share is currently mounted. Supply your own icons.
I have backgrounded the smbclient scan (I know you are not keen) This might create a race condition editing the server shares file if the user keeps clicking the server. (I'm too tired and not sure). It ought to be possible to run all the smbclient calls in parallel. If I tried starting this on my machine at uni nbtscan, might manage to return 100 servers in 1 second this would keep smbclient busy for a very long time. I realise that environment is somewhat extreme but it might be worth considering
Another use case you might consider is allowing direct entry of the ip of a server to connect to.
Code: Select all
--- /usr/local/lameSMBxplorer/lameSMBxplorer 2010-01-03 00:08:08.000000000 +0000
+++ lameSMBExplorer.hw1 2010-01-11 14:24:54.000000000 +0000
@@ -87,6 +87,9 @@
style "gtk-smb-tree" {
stock["lamesmb-server"] = {{"lamesmb.png"}}
stock["lamesmb-share"] = {{"lameshr.png"}}
+ stock["lamesmb-noshares"] = {{"lamenoshrs.png"}}
+ stock["lamesmb-scanning"] = {{"lamescanning.png"}}
+ stock["lamesmb-mounted"] = {{"lamemounted.png"}}
base[NORMAL] = "#FFFFF0"
text[NORMAL] = "#0041BD"
GtkTreeView::odd_row_color = "#f4f4f4"
@@ -171,9 +174,17 @@
OIFS=$IFS; IFS=$'\n'
for OneServer in $(<$nbtFile)
do
+ IFS=$OIFS
SvrNBT=${OneServer#*|}
SvrIP=${SvrNBT}; SvrIP=${SvrIP/|*}
- SvrNBT=${SvrNBT#*|}; SvrNBT=${SvrNBT/|*}
+ echo "lamesmb-scanning|..Still Scanning..|lameSMBExplorer">"$shrFile.$SvrIP"
+ done
+ for OneServer in $(<$nbtFile)
+ do
+ IFS=$OIFS
+ SvrNBT=${OneServer#*|}
+ SvrIP=${SvrNBT}; SvrIP=${SvrIP/|*}
+ SvrNBT=${SvrNBT#*|}; SvrNBT=${SvrNBT/|*}; SvrNBT=$(echo $SvrNBT | sed 's/[ ]*$//')
SvrMAC=${OneServer/*|}
# This filter needs rethinking ...
if [ "$SvrMAC" = "00-00-00-00-00-00" ]; then
@@ -191,7 +202,8 @@
if [ "$shrList" ]; then
echo "$shrList" >"$shrFile.$SvrIP"
else
- :>"$shrFile.$SvrIP"
+ #:>"$shrFile.$SvrIP"
+ echo "lamesmb-noshares|..No Shares..|lameSMBExplorer">"$shrFile.$SvrIP"
fi
[ "$shtty" ] && echo "$shrList">$shtty
done
@@ -201,8 +213,28 @@
function LookUpShares()
{
+ :>$shrFile
[ "$shtty" ] && echo "LookUpShares:$ServerIP">$shtty
- cp "$shrFile.$ServerIP" $shrFile
+ nbtName=$(awk -F"|" '{if ($2 == "'$ServerIP'") {print $3"|"$7}}' $nbtFile)
+ dmnName=$(echo ${nbtName#*|})
+ nbtName=$(echo ${nbtName/|*})
+ OIFS=$IFS; IFS=$'\n'
+ for OneShare in $(<"$shrFile.$ServerIP")
+ do
+ IFS=$OIFS
+ ShareName=${OneShare#*|};ShareName=${ShareName/|*}
+ mountchk=$($imount | grep -c "/mnt/network/$nbtName/$ShareName ")
+ if [ $mountchk -eq 0 ]; then
+ if [ "${OneShare#*|*|}" = "lameSMBExplorer" ]; then
+ echo ${OneShare} >> $shrFile
+ else
+ echo 'lamesmb-share|'${OneShare#*|} >> $shrFile
+ fi
+ else
+ echo 'lamesmb-mounted|'${OneShare#*|} >> $shrFile
+ fi
+ done
+ cp $shrFile "$shrFile.$ServerIP"
}
function MountShare()
@@ -366,7 +398,7 @@
$gtkdApp -p lameScanBox -c 2>&1 >/dev/null &
spid=$!
ScanNBT
- FindShares
+ FindShares &
[ -e /proc/$spid ] && kill $spid &>/dev/null
}