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

Me

Circulation Situation

What do I mean by the last mile?


Dartmouth College


~7,000 students (graduate and undergrad)

Innovative Interfaces Inc. - Millennium ILS

locally hosted  / root access to the server

3 "Real Programmers" in the library

Everything about me that fits on a slide:

Systems Librarian

Limited Unix background

No programming background =>

Love to make systems work for users (patrons and/or staff) 

Circulation Situation


Six branches that regularly circulate materials

Eight circulation desks, each sending notices 

Most notices go via email, a few are mailed

Staff went into the system each day to tell the system to send notices...manually?

"please returneth the digital camera posthaste"

There's an app for that


System provides autonotice functions, but the feature hadn't been turned on

Previous implementation history

The problem: the system won't handle printing notices automatically.


Last Mile Problem

connections from the backbone of a network to the end users are the "most expensive part of the system...[and] the most difficult to upgrade" 


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


Pick up the files and convert them to pdfs

Email them to the circulation desk that created them

Bonus points: Email the autonotice log to the system administrator (me) to check on any errors reported

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


I don't want to be a programmer, but I need to speak their language

Writing the code using the toolkit I have at hand (UNIX command line) will be useful experience

...and I won't be taking up the programmer's time until I know that the goal is feasible
$ 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...


Reality check - remember, I wrote this.

  • 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


A programmer took my script and rewrote it:

  • 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?


Notices are sent out multiple times per day, with any that need to be printed being run through this process and winding up in the inbox of the interested party

Staff at those 8 circulation desks don't "send notices" anymore, it just happens

Errors in autonotices log are seen immediately

Conclusion


You can write a program that works, even if you need some help




Another Conclusion

Prototyping is an effective communication tool

Acknowledgements


People:
Eric Bivona - Programmer
Lynn Amber - Access Services Librarian

Book:

Questions?




Joe Montibello





http://www.rvl.io/joemontibello/autonotices-to-print/

autonotices to print

By joemontibello

autonotices to print

  • 2,000