1#!/bin/sh
2# $Id: ncpprint,v 1.1.1.1 2008/10/15 03:28:26 james26_jang Exp $
3# This script is an input filter for printcap printing on a unix machine. It
4# uses the nprint program to print the file to the specified ncp-based 
5# server and queue.
6# For example you could have a printcap entry like this
7#
8# ncp:lp=/dev/null:sd=/usr/spool/ncp:sh:if=/usr/local/bin/ncpprint
9#
10# which would create a unix printer called "ncp" that will print via this 
11# script. You will need to create the spool directory /usr/spool/ncp with
12# appropriate permissions and ownerships for your system.
13
14#
15# This version reads from a ${SPOOLDIR}/general.cfg
16#  file or uses the PRINTCAP_ENTRY environment variable
17#  passed by LPRng,  and the 'ncp_options' value in it.
18#  The username and password information are in an 'authfile'
19#
20#
21# If you use the ${SPOOLDIR}/general.cfg file, it should contain:
22#   server=PC_SERVER
23#   printer=PRINTER_QUEUE
24#   authfile=auth
25#
26#
27# Example:
28#   server=NWSERVER
29#   printer=P_QUEUE1
30#   authfile=auth
31# authfile has:
32#   username=fred
33#   password=
34#
35# You can also  put options into the printcap ncp_options entry
36# ncp:lp=/dev/null:sd=/usr/spool/ncp:sh:if=/usr/local/bin/ncpprint
37#   ncp_options= server=NWSERVER printer=P_QUEUE1 authfile=authfile
38#
39
40if [ -f ./general.cfg ] ; then
41	. ./general.cfg
42fi
43options=`echo "${PRINTCAP_ENTRY}" | sed -n -e 's/:ncp_options=//' `
44if [ -n "$options" ] ; then
45	eval export $options
46fi
47
48# get username and password values
49if [ -n "$authfile' -a -f "$authfile" ] ; then
50	. $authfile
51fi
52
53usercmd=""
54if [ "$username" != "" ]; then
55   if [ "$password" != "" ]; then
56		usercmd="-U $username -P $password"
57   else
58        usercmd="-U $username -n"
59   fi
60fi
61
62#cat > /tmp/printout
63#x_command=""
64#case $translate in
65#  yes) x_command="translate" ;;
66#esac
67#echo $server $password $translate $x_command > /tmp/ncpprint.log
68
69/usr/bin/nprint -S $server -q $printer $usercmd -N - 2>/dev/null
70