#!/bin/sh
#
#
# ident "@(#)bbprint.sh	1.2 01/04/09 SMI"
#
# Copyright (c) 2000 by Sun Microsystems, Inc.
# All rights reserved.
#

. $BBROOT/etc/bbchroot.rc

# Path for use within chroot

# Putting the temporary print output file into a
# per user directory is probably better -
# tmp files left for whatever reason will
# be removed when that home directory removed
# on user logout.

CHRFILE=printfile.$$

# Have to put cat into bbchr/root/bin for this
# Note using read and echo of a line was slow and
# modified the file - printed PS as text  rather than
# ran the PS file to produce output.

# Acroread writes PS into a tmp file and passes it
# as an arg to print command. NSCP writes PS
# to stdout.

if [ $# -gt 0 ]; then
        FILE=`/bb/bin/bbmv $1 $CHRFILE` # change i-node
	res=$?
        echo "" > $1            	# 1 byte file for acro to
                                	# remove, -n not in sh
else
        FILE=`/bb/bin/bbmv - $CHRFILE`	# bbmv will read from stdin 
	res=$?				# and write to $HOME/tmp/$CHRFILE
fi

# Other side of pipe removes file when printed

if [ $res = 0 ]; then
	echo prtdlg $FILE > /doors/$USER
fi

