[ UP ] cgi
[archserver.git] / cgi / samba / list_connects.sh
blobde49ba69515ebaf72061806578680e5a4340d395
1 #!/bin/sh
3 declare -a smbpid
4 smbstatus -p | sed /^$/d|sed 1,/^-/d > /tmp/smbpid
6 echo -e '<hr size=1>
7 <h3><font color=blue>当前所有连接</color></h3>
9 echo '<table cellspacing="2" cellpadding="8" border="0" width="90%">'
10 #echo "<tr class="color_table_heading"><th>User</th><th>Share</th><th>Pid</th><th>Connect From</th></tr>"
11 echo "<tr bgcolor=\"#c6d5a8\"><th>用户名</th><th>访问共享名</th><th>进程id</th><th>连接自计算机</th></tr>"
12 while read line
13 do
14 eval pid=$(echo $line | cut -f1 -d' ')
15 eval smbpid[$pid]=$(echo $line|cut -f2 -d' ');
16 done < /tmp/smbpid
17 rm -f /tmp/smbpid
19 smbstatus -S | sed '/^$/d' | sed '1,/^-/d' > /tmp/smbshare 2>/dev/null
21 count=1
22 echo -e '<form name="delete_users">'
23 while read line
25 [ $_n = 2 ] && _n=1 || _n=2
26 pid=$(echo $line | cut -f2 -d ' ')
27 echo "$_n ${smbpid[$pid]} $line " |awk '
28 { print "<tr class=color_table_row"$1"><td>"$2"</td><td>"$3"</td><td>"$4"</td><td>"$5"</td></tr>" }'
29 done < /tmp/smbshare
31 echo "</form>"
32 echo "</table>"
33 rm -f /tmp/smbshare