#! /bin/sh
# This script gets invoked by a hacked TFTP server.
# It is intended to allow students to print router config files.
#
# first line of stdin is meta information (IP address, file name).
# remainder of stdin is file contents.

read ipaddr filename

head1="Printed at AfNOG 2004 workshop"
head2="[$ipaddr] $filename"

controlC="$(printf '\003')"


sed "s/${controlC}/\^C/g" | /usr/bin/tee /tmp/tftp-print.$$ | /usr/local/bin/a2ps -q --header="$head1" --stdin="$head2" | lpr -Plp
