root / pykota / branches / specialauth / bin / mailandpopup.sh

Revision 3133, 1.4 kB (checked in by jerome, 18 years ago)

Changed copyright years.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#! /bin/sh
2#
3# PyKota - Print Quotas for CUPS and LPRng
4#
5# (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet <alet@librelogiciel.com>
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#
16PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/opt/bin
17#
18# user's name
19UNAME=$1
20# printer's name
21PNAME=$2
22# message's recipient
23RECIPIENT=$3
24# message's body
25MESSAGE=$4
26#
27# Convert message body to UTF8 for WinPopup
28UTF8MESSAGE=`echo "$MESSAGE" | iconv --to-code utf-8 --from-code iso-8859-15`
29#
30# Send original message to user
31mail -s "Print Quota problem" $RECIPIENT <<EOF1
32$MESSAGE
33EOF1
34#
35# Send some information to root as well
36mail -s "Print Quota problem on printer $PNAME" root <<EOF2
37Print Quota problem for user $UNAME
38EOF2
39#
40# Launch WinPopup on user's host (may need a real Samba or NT domain)
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:
44IPS=`smbstatus -b -u "$UNAME" | grep "$UNAME" | cut -d '(' -f 2,2 | cut -d ')' -f 1,1`
45for i in $IPS ; do
46    echo "$UTF8MESSAGE" | smbclient -M "$UNAME" -I $i 2>&1 ;
47done
Note: See TracBrowser for help on using the browser.