Autonotices
to Print
The last mile
Joe Montibello, MLIS
Library Systems Manager
Dartmouth College Library
joseph.montibello@dartmouth.edu
What we'll cover:

Background
Dartmouth College
~7,000 students (graduate and undergrad)
Everything about me that fits on a slide:
Love to make systems work for users (patrons and/or staff)
Circulation Situation
"please returneth the digital camera posthaste"
There's an app for that
Last Mile Problem
The network can't be considered a success until it bridges the last mile
Autonotices isn't a success if you still have to check for and print some notices manually
Idea
A little more detail
Make sure the filenames are readily parseable
Iterate through the files in the directory
read the first six characters and use that to determine which circ desk sent the notice job (and therefore, which email address to send to)
convert the file to pdf
attach the file to an email
Proof of Concept
$ cat autoprintdata bakcir;baker.circulation@dartmouth.edu bakres;baker.reserves.desk@dartmouth.edu dancir;dana.library.circulation@dartmouth.edu felcir;feldberg.circulation@dartmouth.edu joncir;jones.media.center@dartmouth.edu krecir;kresge.library@dartmouth.edu padcir;paddock.music.library@dartmouth.edu joesys;joseph.montibello@dartmouth.edu
A text file with the codes and addresses in it
#!/bin/bash # autoprintctl # # This script lists the filenames in the /iiidb/marc directory # that include ".autonotices.p" in them and runs the script # "autoprintjob" against each. But first, email the autonotices# log so that it gets seen regularly. text="Hi,\ \ The attached file is an autonotices log. This file is kept on the Millennium server, so you don't need to keep copies.\ \ If you have any questions or problems, please contact ... echo $text | mutt -s Autonotices -a /iiidb/errlog/autonotices.log joseph.montibello@dartmouth.edu ls /iiidb/circ/autonotices | grep *.autonotices.p | xargs /home/jmontibello/ap/autoprintjob
So for each file, we're going to run the following code:
$ cat autoprintjob #!/bin/bash set -x set -e # autoprint # # This program accepts a series of filenames (separated by # spaces) from stdin, converts the text to pdf, and emails the # resulting files to a user. This was designed to work with # autoprintctl, for notices found in iiidb/marc/ on olympia. noticedir="/iiidb/circ/autonotices" scriptdir="/home/jmontibello/ap" email="global variable"
Set up variables
function getemail #checks the first six characters of the input name against a #table of codes and the corresponding email addresses for the #circulation points that will get the notices. { exec<"${scriptdir}/autoprintdata" inputcode=` echo $1 | cut -c 1-6 ` while read line ; do checkcode=${line%;*} if [ "$inputcode" = "$checkcode" ]; then email=${line#*;} fi shift done }
Function to get the email address if a given line matches an address
#in this loop, we convert each file to pdf and send it while (( "$#" )); do getemail $1 # create output.ps from the III-generated print file enscript -q --margins=::10: -L 60 -B -p "${noticedir}/ output.ps" "${noticedir}/$1" # make a string named the same as $1, but with .pdf extension outfile=${1/%.*/.pdf} #echo $outfile # convert output.ps to $1.pdf ps2pdfwr ${noticedir}/output.ps ${noticedir}/$outfile # now, send the email. echo "This is a test of autoprintjob, sending copies to Joe." | mutt -a "${noticedir}/$outfile" -s "To = $email" joseph.montibello@dartmouth.edu echo "These are the printed autonotices." | mutt -a "${noticedir}/$outfile" -s "$outfile" "$email"
#clean up - for now, we'll move them. Maybe later, clear them? mv ${noticedir}/output.ps ${noticedir}/sent/output.ps mv ${noticedir}/$outfile ${noticedir}/sent/$outfile mv ${noticedir}/$1 ${noticedir}/sent/$1 #now, move onto the next print file shift done
Move the files out of the directory so they won't get mixed in the next time this runs
It worked, but...
- No error handling
- Code/email combinations are in a random file
- Depends on a number of different shell tools, any one of which could break my script when they get upgraded
The hand-off
- In a language that our department has depth in
- In one self-contained script
- With error-handling
- With email addresses mapped from login names instead of an arbitrary coding system
- Log file doesn't get sent all together - it only sends mail with relevant error messages
Where are they now?
Conclusion

Another Conclusion


Acknowledgements
People:
Questions?
http://www.rvl.io/joemontibello/autonotices-to-print/
autonotices to print
By joemontibello
autonotices to print
- 2,133