1819695 Members
3683 Online
109605 Solutions
New Discussion юеВ

print to an email

 
SOLVED
Go to solution
Steve Lewis
Honored Contributor

print to an email

Has anybody ever set-up a pseudo-printer model which sends the output to an email to the user instead of the printer?

If so, can they post it, or give me a procedure to configure it?

We are having problems with non-IT management moving their staff around on a daily basis (but not the printers) and expecting the UNIX printouts to follow them by magic. Since the application controls a lot of printing I do not want the overhead and risk of doing daily printer configuration changes - email the reports to them let them sort out their own printers in windows if they want to.
The application does not allow people to specify their own print destinations - that would be a huge change for us.

If anyone has any other creative solutions to this please say so.
10 REPLIES 10
Geoff Wild
Honored Contributor

Re: print to an email

How about remove the non IT management?

You could always use a wrapper script of sorts...

I don't print to email - but I don't see why not - I redirect SAP printing to a wrapper script - depending on the printer - I do different things:

Example:

case $P in

C003)
xebec
exit
;;

dschq)
dschq
exit
;;

hrchq)
hrchq
exit
;;

oschq)
oschq
exit
;;

dserp)
dserp
exit
;;

qaerp)
qaerp
exit
;;
*)
print_hp
exit
;;
esac



Example - the XEBEC one - ftp's a file:

#################################################
# xebec
#################################################
function xebec
{
Outpath=/var/spool/lp/receive/XEBEC
PSMServer=prprt
# Strip path if any and take only filename
Filename=`echo $F | sed 's/.*\///'`
# Append filename to output file path
Fileout=$Outpath/${Filename}
rcp $F ${PSMServer}:$Outpath
rtc=$?
if test "$rtc" != 0
then
echo "Cannot move $F to $Fileout"
echo "Cannot move $F to $Fileout" 2>&1
exit $rtc
fi
# ftp the file
remsh $PSMServer /usr/local/lp/xebecftp $Fileout 2>&1 /dev/null
rtc=$?
if test "$rtc" != 0
then
echo "xebecftp returned error code $rtc"
echo "xebecftp returned error code $rtc" 2>&1
exit $rtc
fi
exit



So - you could email...


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Pete Randall
Outstanding Contributor

Re: print to an email

Steve,

Not exactly what you're looking for, but a suggestion for a different way to handle it.


We use one of the GECOS fields (office location) in /etc/passwd to store the user's default printer and then use /etc/profile to retrieve it and set it like this:

# Set each user's individual preferred printer
PRINTER=`/usr/bin/pwget -n $USER | line | cut -d, -f2`;export PRINTER
LPDEST=$PRINTER;export LPDEST

This way, when a user changes locations, it's a simple matter to change /etc/passwd and the next time they log in, they're directed to their new printer.

Might work for you.


Pete

Pete
Steve Lewis
Honored Contributor

Re: print to an email

Pete,

Using the GECOS field is our current solution - just as you documented. The problem I have is that sometimes the user's new printers have never been configured on the server or the users are unable to give me the printer details and I have no remote support at these sites.

I don't want to have to update lots of these entries each day, especially with our new SOX compliant change-management overhead.

Geoff, where does that script get put?




Geoff Wild
Honored Contributor

Re: print to an email

Scripts are in /usr/local/lp

I've attached them in there entirety.


Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Geoff Wild
Honored Contributor
Solution

Re: print to an email

Scripts are in /usr/local/lp

I've attached them in there entirety.

Rgds...Geoff

Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Steve Lewis
Honored Contributor

Re: print to an email

Although Geoff got a bunny for his troubles he is still presenting a bespoke solution based on a non-standard print command, not a /usr/spool/lp/ based solution. Our application prints using lp commands to the user's default printer as is defined in the password file.

Could I just copy the dumb model script to something else, remove some of the formatting and mailx/sendmail instead of lprcat and lpbanner ?

Any comments?

RAC_1
Honored Contributor

Re: print to an email

I am think about something. How about defining a file as a printer and having another process monitor this file peridically OR monitor lp log file for new print job and then do a lp for a file. This other process will when notices a file will print it.

You can have a file as printer by doing following.

touch /tmp/print_file

chown lp:bin /tmp/print_file

chmod 644 /tmp/print_file

lpadmin -pprint_file -v/tmp/print_file -mdumb

lpshut and lpsched

that's ALL.

lp -dprint_file /etc/hhosts

check /tmp/print_file
There is no substitute to HARDWORK
Steve Lewis
Honored Contributor

Re: print to an email

RAC, you forgot to enable the printer and accept requests to it, but now I have done that, its getting close.

I tried to copy the dumb printer model to a new one called email, which uses mailx on the file being printed.

The current problem is that the /etc/mail/aliases file translates my UNIX userid into StephenLewis@mycompany and
the lp file contains this:
The flags you gave are used only when sending mail.
Lewis...User unknown
Stephen... User unknown
/var/spool/lp/dead.letter... Saved message

Steve Lewis
Honored Contributor

Re: print to an email

OK guys thanks for your help.

I fixed the bug which was with my stupid code and now it works.
I finally did it my way - created a pseudo device file for lpadmin and made a copy of the dumb model script called email.

Instead of writing the data to the file it simply uses mailx straight to the userid for each file, not using a banner and forcing only 1 copy.
/etc/mail/aliases translates the unix ids to windows fqdn ones.
It doesn't require any process continuously looping around searching for requests.
No application code change required for that, thank goodness.
So now subject to change board approval, users will be able to request an LPDEST of 'email' and all their reports will go to their inbox, so they can print from Outlook, managing their own printers from windows and not bother us sysadmins.
Feet up on the desk again...zzzzzz...





Geoff Wild
Honored Contributor

Re: print to an email

Steve - very cool and well done - any chance you can post your code?

Thanks...Geoff

Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.