Precisely Speaking
February 08, 2012, 02:47:08 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: So what's news with you?  Tell us about it in "Getting To Know You"!
 
   Home   Help Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: AIX email attachment "printer"  (Read 804 times)
Alex Copeland
Professional
***
Posts: 21


Artist's rendering


« on: March 21, 2010, 12:43:16 PM »

There are other methods to accomplish this, but the mutt email client works well for what we do with it.

Code:
#!/bin/bash
#
# attachemail
#
# This is a quick and dirty "email printer."
# The "print" is sent as a mime attachment
# using mutt (see Linux Tools for AIX).
# It uses "whoami" to send mail to the user
# invoking the command (or using the printer).
# As written, the script uses a separate /etc/aliasUDusers
# file to cross-reference UD users to email addresses.
# The format is:
#
# [UDUSER]:email@address.whatever
#
# Set up a printer in AIX to print to a program.
# The /etc/qconfig stanzas should look something like
# [queuename]:
#     device = attach
#     up = TRUE
# attach:
#     backend = /usr/local/bin/attachemail
#     align = FALSE
#
#
# Alex Copeland
# revised August 2009
# acopeland@brake.com


TMP="/tmp/attachemail$RANDOM.txt"
ALIASFILE="/etc/aliasUDusers"

cat $* > "$TMP"

EMAIL=$(grep "$(whoami):" "$ALIASFILE" |
  awk -F":" '{print $2}')
if [ -n "$EMAIL" ]
  then
    /usr/bin/mutt -s "System Print Text Attachment" -a "$TMP" "$EMAIL" \
    < /dev/null
fi

rm -f "$TMP"
exit 0
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!