Revision 1697, 1.4 kB
(checked in by jalet, 20 years ago)
|
Improved messaging system when IP address is needed for smbclient -M
|
-
Property svn:eol-style set to
native
-
Property svn:executable set to
*
-
Property svn:keywords set to
Author Date Id Revision
|
Rev | Line | |
---|
[1241] | 1 | #! /bin/sh |
---|
| 2 | # |
---|
| 3 | # PyKota - Print Quotas for CUPS and LPRng |
---|
| 4 | # |
---|
[1257] | 5 | # (c) 2003-2004 Jerome Alet <alet@librelogiciel.com> |
---|
[1241] | 6 | # You're welcome to redistribute this software under the |
---|
| 7 | # terms of the GNU General Public Licence version 2.0 |
---|
| 8 | # or, at your option, any higher version. |
---|
| 9 | # |
---|
| 10 | # You can read the complete GNU GPL in the file COPYING |
---|
| 11 | # which should come along with this software, or visit |
---|
| 12 | # the Free Software Foundation's WEB site http://www.fsf.org |
---|
| 13 | # |
---|
| 14 | # $Id$ |
---|
| 15 | # |
---|
[1527] | 16 | PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/opt/bin |
---|
| 17 | # |
---|
[1241] | 18 | # user's name |
---|
| 19 | UNAME=$1 |
---|
| 20 | # printer's name |
---|
| 21 | PNAME=$2 |
---|
| 22 | # message's recipient |
---|
| 23 | RECIPIENT=$3 |
---|
| 24 | # message's body |
---|
| 25 | MESSAGE=$4 |
---|
| 26 | # |
---|
| 27 | # Convert message body to UTF8 for WinPopup |
---|
[1527] | 28 | UTF8MESSAGE=`echo "$MESSAGE" | iconv --to-code utf-8 --from-code iso-8859-15` |
---|
[1241] | 29 | # |
---|
| 30 | # Send original message to user |
---|
[1527] | 31 | mail -s "Print Quota problem" $RECIPIENT <<EOF1 |
---|
[1241] | 32 | $MESSAGE |
---|
| 33 | EOF1 |
---|
| 34 | # |
---|
| 35 | # Send some information to root as well |
---|
[1527] | 36 | mail -s "Print Quota problem on printer $PNAME" root <<EOF2 |
---|
[1241] | 37 | Print Quota problem for user $UNAME |
---|
| 38 | EOF2 |
---|
| 39 | # |
---|
| 40 | # Launch WinPopup on user's host (may need a real Samba or NT domain) |
---|
[1697] | 41 | # In some cases the username does not suffice for smbclient to send a message; |
---|
| 42 | # we must also supply the IP address. This will use smbstatus to get all IPs |
---|
| 43 | # where the user is logged in and send the message there: |
---|
| 44 | IPS=`smbstatus -b -u $UNAME | grep '(' | cut -d'(' -f 2 | cut -d')' -f 1` |
---|
| 45 | for i in $IPS; do |
---|
| 46 | echo $UTF8MESSAGE | smbclient -M "$UNAME" -I $i 2>&1 >/dev/null; |
---|
| 47 | done |
---|