root / pykota / trunk / bin / mailandpopup.sh @ 3268

Revision 3260, 1.7 kB (checked in by jerome, 17 years ago)

Changed license to GNU GPL v3 or later.
Changed Python source encoding from ISO-8859-15 to UTF-8 (only ASCII
was used anyway).

  • 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
4#
5# (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet <alet@librelogiciel.com>
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18#
19# $Id$
20#
21PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/opt/bin
22#
23# user's name
24UNAME=$1
25# printer's name
26PNAME=$2
27# message's recipient
28RECIPIENT=$3
29# message's body
30MESSAGE=$4
31#
32# Convert message body to UTF8 for WinPopup
33UTF8MESSAGE=`echo "$MESSAGE" | iconv --to-code utf-8 --from-code iso-8859-15`
34#
35# Send original message to user
36mail -s "Print Quota problem" $RECIPIENT <<EOF1
37$MESSAGE
38EOF1
39#
40# Send some information to root as well
41mail -s "Print Quota problem on printer $PNAME" root <<EOF2
42Print Quota problem for user $UNAME
43EOF2
44#
45# Launch WinPopup on user's host (may need a real Samba or NT domain)
46# In some cases the username does not suffice for smbclient to send a message;
47# we must also supply the IP address. This will use smbstatus to get all IPs
48# where the user is logged in and send the message there:
49IPS=`smbstatus -b -u "$UNAME" | grep "$UNAME" | cut -d '(' -f 2,2 | cut -d ')' -f 1,1`
50for i in $IPS ; do
51    echo "$UTF8MESSAGE" | smbclient -M "$UNAME" -I $i 2>&1 ;
52done
Note: See TracBrowser for help on using the browser.