#!/bin/csh -f
set HOSTDIR = hosts/
set PRINTCAP = printcap/
set PRINTERDIR = printers/

foreach host ($*)
	set host = $host:t
	set host = $host:r
	if ( ! -e ${HOSTDIR}${host} || ! -f ${HOSTDIR}${host} ) then
		echo Host ${host} does not exist 
		exit 1
	endif
	echo Updating printcap for ${host}
	echo  "# printcap file created " `date` > ${PRINTCAP}${host}.printcap
	if( $status ) then
		echo "error creating ${HOSTDIR}${host}.printcap"
		exit 1
	endif
	echo host $host has the following printers:
	cat ${HOSTDIR}${host}
	foreach printer (`cat ${HOSTDIR}${host}`)
		if ( -f ${PRINTERDIR}${printer}) then
			cat ${PRINTERDIR}${printer} >> ${PRINTCAP}${host}.printcap
		else
			echo No printcap for ${printer}
			exit 1
		endif
	end
end
exit 0
