Problem
How do I add a HPNP printer with SCO Unix and share it with, say, a Windows File and Print sharing system such as AFPS?
Solution
The example below was developed with SCO OpenServer5 but can also be applied to other SCO operating system versions.
1. The printer is named "prn001" with a standard description, such as:
Office,Location/Dept,Manu/ModelFor example: UK,Support,HP LaserJet IVThe printer name should be less than 8 characters.
For this example the printer is not defined in the Domain Name Service (DNS).
2. Add the printer to the lp subsystem using "/usr/lib/hpnp/hpnpcfg" or "scoadmin printer".
An additional example is available at the end of these steps called "add_printer".
Use "add_printer" to add a printer, if the printer is connected via a Jet Direct Card.
2a. Ensure that the printer is now in /etc/hosts file in the
format:xxx.xxx.xxx.xxx prnXXXX # Description (as above), eg:
#
# Local Printers.
# --------------
xxx.xxx.xxx.xxx prn0001 # UK,Support,HP LaserJet IV2b. The script will ask you for an interface to use from:/usr/spool/lp/modelPick the appropriate model for that printer, for example if the printer uses HPGL then use HPLaserJet.
If you use the printer just from the PC's and not from Unix, then use the "passthrough" interface. You will need to ensure that the BANNER is turned off in "scoadmin printers".
Alternatively, use the example "model", laserjethpnp or laserjetIIIsi from /usr/lib/hpnp/sh to print from Unix and also print from Windows via AFPS.
You can also slightly modify this HPNP model by denying banners
from being printed as a default. ie:# print the banner if no banner not specified and reversing is not
# specified
if [ -n "$banner" -a -z "$reverse" ]
then case "$bannerpagemode" in
def);;
ubbin) echo "\033&l1H\c";;
lbbin) echo "\033&l4H\c";;
esac
# do_banner
if [ "$duplex" = "yes" -a "$even_bans" = "no" ]
then
echo "\f\c"
fi
echo "\033E\c" # Reset Printer
echo "\033)0B\c" # Secondary character set line draw
echo "\033&k2G\c" # Set line termination mode.
fi2c. If the printer is connected via a terminal server, chase card,
serial port or parallel port then add the printer manually.a) /usr/lib/lpadmin -p <printer> -v /dev/null -m model
-D ["comment" (ie. printer description, ie as above]
-o nobannerYou can see the comments of a printer with the command
# lpstat -p -Db) accept <printer>c) enable <printer>2d. If you need to add a printer manually to a JetDirect Card
ie. it is not a HP printer attached then use:/usr/lib/hpnp/hpnpcfgwith the appropriate model for the printer connected.
2e. Manually, by hpnpcfg# /usr/lib/hpnp/hpnpcfgFollow the instructions below and select the appropriate option:
4 - Verify network printer connectivity 5 - Verify network printer operation (print Text/Postscript/PCL) 6 - Add printer
All using "prn0001" or you can use IP address for testing only.
This will create:/usr/lib/lp/admins/lp/interfaces/<printer> - this is a standard
HPNP script/usr/lib/lp/admins/lp/interfaces/model.orig/<printer> - this is
the model selected.To add a description go into "scoadmin" and select the Printer Manager and enter the description above for the printer.
Manually:/usr/lib/hpnp/hpnpf -n -v -R -x xxx.xxx.xxx.xxx <file>3. Sharing a PrinterIf you have created a printer using the "add_printer" script then you should not need to share the printer, however, to check run the "net print" command.
When sharing this printer via AFPS share using the printer name:
SHPRNnnn because they can't be the same name.Go into scoadmin |Printers|Printer Manager|Settings|ControlEnsure that there is also a description for the printer as well.
eg. UK,Support,HP LaserJet IVnet share <sharename} /REMARK:"<Standard Description>"eg. net share shprn001 /REMARK:"UK,Support,HP LaserJet IV"This is because AFPS effectively creates a printer class.
4. Using the Printer on the Windows clientsConfigure the printer on the PC by going into Network Neighbourhood and selecting the server you want to print from. Pick the printer and let Windows install the printer using the Printer Wizard. When prompted select the LATEST driver.
Naming of the printer is important. Let the printer name be the
one prompted by the Print Wizard (For example, HP LaserJet 4M
Plus) pick the name of the driver. If you have multiple
printers using the same driver then you might say:"HP 4M - SHPRNXXX" for that user's PC.
Ensure that you go into the COMMENTS for that Printer and put the standard COMMENTS in, for example:
UK,Support,HP LasetJet IV.Ensure that you print a test page.
5. Legacy ApplicationsIf you have a Legacy Application that uses an old printer name then you could add the printer with the the name defined above.
What about the Legacy App, though, that uses the old name?
You actually have 2 options, either add the printer again with the old legacy printer name OR create a CLASS of printer with the old legacy name that simply points to the new KCP name, but check that the interfaces aren't different.
Use the command:/usr/lib/lpadmin -p prn001 -c p-team-lw2
accept p-team-lw2TROUBLESHOOTING:
---------------
If you find that the printer does not print Microsoft Word tables
properly then try going into the:scoadmin | Printers | Printer Manager | Settings | Advanced | Terminfooption and setting the printer's TERMINFO setting to "hplaserjet".
An other option on the PC Client is to try changing the Spool Settings of the printer from "Print Directly to Print" to "Spool print jobs".
Check the BIOS of the printer.Check also the Windows Driver of the printer.This problem has been seen
on the HP LaserJet 4M. Even though the printer has sufficient memory
the driver may not be able to address it correctly. Try a PostScript
Driver.PRINTING UK POUND SIGNS:The first issue is to ensure that the character entered on the screen is actually a pound sign:
The UK pound sign character is "\0234". You can see this character if
"vi" a file on the console or if you telnet to the server. ie. within
"vi" if you insert SHIFT-3, ie. a pound sign, then it should display as
\234. When you save this file and "cat" this file, it should display a
pound sign. Should the display give you \243 then you will see a "u"
with a dash above it then it will print a pound sign if you print to a
print using a "postscript" interface.To ensure that you see \0234 in vi then ensure that your international Settings Manager (scoadmin international) is set for "C Language Set", Internal Codeset for ISO8869-1, Keyboard at.iso.ukd and Console Codeset of ISO8859-1 and that the "ansi" terminal definition is selected when logging onto the server.
Then we need to ensure that the same characters are displayed correctly from "telnet":
Use "telnet" from Windows 2000/Windows XP, TermLite or TermVision to
telnet to the server and determine that \234 is also displayed in "vi"
as the Terminal Emulator will also be a factor. For example within the
TermVision emulator the default in Properties->Terminal->Advanced->
Code Page and Keyboard Translation is "International (437)" and "SCO
(Mapkey)". If you change the values to "ISO8859" and "ASCII"
respectively then you will see a pound sign. Change them again to
"Multlingual (850)" then you will see the "u" character when you press
SHIFT-3 in "vi".To print the UK Pound Signs we then have to set the printer up:
Printing UK Pound Signs will be dependent on the printer itself being able to print the character depending on the character set the printer is configured to.
HP Printers configured via either the "HPLaserJet", "laserjethpnp" or "standard" model or those printers running "LPD" should be able to print the pound sign.
DELETING A PRINTER:If the printer is an HPNP Printer then use the /usr/lib/hpnp/hpnpcfg program to delete the printer from the spooler.
Alternatively you can delete the printer using:
/usr/lib/lpadmin -x <printer name>You may also have to:Remove Entry from /etc/hosts, and /etc/services, /usr/spool/lp/admins/lp/interfaces and /usr/spool/lp/admins/lp/interfaces/model.orig
Remove Entry from /etc/printcap, if the printer is a LPD Printer.
Remove Entry from /usr/spool/lp/remote, if the printer is a Remote Printer.
If the printer is also a shared AFPS Printer then:
net share <SHARENAME> /DELETE, if the printer is an AFPS Printer net print <PRINTERNAME> /DELETE, if the printer is an AFPS Printer
You may also have to:/usr/lib/lpadmin -x {SHARENAME}----- add_printer -----:
#
# Add a Printer Script
#
echo "\nAdd the Printer to /etc/hosts file in the format :-\n"
echo "xxx.xxx.xxx.xxx prnXXX # Building,Location,Manu/Model"
echo " ===\n"
echo -n "\nEnter first Printer Identifying Number (eg: 002) (Enter X to eXit): "while read PRN_NUMBER
do
if [ ! ${PRN_NUMBER} = "" ]; then
:
else
exit 1
fi
if [ ${PRN_NUMBER} = "X" ] || [ ${PRN_NUMBER} = "x" ];
then
:
break
elseUNIX_PRN="prn${PRN_NUMBER}"
SHARE_PRN="SHPRN${PRN_NUMBER}"LINE=`grep $UNIX_PRN /etc/hosts`
if test $? -eq 1
then
echo "This Printer is not added to /etc/hosts yet"
exit 0
else
IP_ADDR=`echo ${LINE} | cut -d " " -f 1`
LTEMP=`echo ${LINE} | cut -d "#" -f 2`
DESC="`echo ${LTEMP}`"
echo "The UNIX NAME is $UNIX_PRN"
echo "The IP ADDRESS for $UNIX_PRN is ${IP_ADDR}"
echo "The Description for $UNIX_PRN is ${DESC}"
echo "The SHARE NAME for $UNIX_PRN is ${SHARE_PRN}"
echo "\nIs this correct (Y/N) [Default=y] ? \c"
read CORRECT
if [ "$CORRECT" = "" ]; then
CORRECT="Y"
fi
if [ ${CORRECT} = "Y" ] || [ ${CORRECT} = "y" ]; then
if [ -x /usr/lib/hpnp/hpnpcfg ]; then
#
# HPNP Parameters.
#
HPNP=/usr/lib/hpnp export HPNP
PATH=$PATH:/usr/lib/hpnp/cfg export PATH
ECHO="echo" export ECHO
cd /usr/lib/hpnp
#
# Test IP Address.
#
echo "\nTEST IP ADDRESS - $DESC"
if [ `uname -s` = "SCO_SV" ]; then
option4 ${UNIX_PRN}
else
echo " "
ping -c 5 ${UNIX_PRN}
fi
echo "\nContinue (Y/N) [Default=y] ? \c"
read CORRECT
if [ "$CORRECT" = "" ]; then
CORRECT="Y"
fi
if [ ${CORRECT} = "N" ] || [ ${CORRECT} = "n" ]; then
exit 0
fi
#
# Test Printer Access.
#
echo "\nTEST PRINTER - $DESC"
option5 ${UNIX_PRN}
echo "\nContinue (Y/N) [Default=y] ? \c"
read CORRECT
if [ "$CORRECT" = "" ]; then
CORRECT="Y"
fi
if [ ${CORRECT} = "N" ] || [ ${CORRECT} = "n" ]; then
exit 0
fi
#
# Add Printer to the Spooler.
#
echo "\nADD PRINTER - $DESC"
if [ ! -f /usr/lib/hpnp/cfg/option6 ]; then
option6sco ${UNIX_PRN}
else
option6 ${UNIX_PRN}
fi
echo "\nAdding Printer's Description and Setting
Permissions ... \c"
if [ `uname -s` = "SCO_SV" ]; then
echo "OpenServer ... \c"
/usr/lib/lpadmin -p${UNIX_PRN} -D"${DESC}" -o
nobanner -b 0
else
echo "3.2v4.2 ... \c"
/usr/lib/lpadmin -p${UNIX_PRN} -D"${DESC}" -o
nobanner
fi
chmod 775 /usr/spool/lp/admins/lp/interfaces/${UNIX_PRN} chown lp:lp
/usr/spool/lp/admins/lp/interfaces/${UNIX_PRN}
chmod 775
/usr/spool/lp/admins/lp/interfaces/model.orig/${UNIX_PRN}
chown bin:lp
/usr/spool/lp/admins/lp/interfaces/model.orig/${UNIX_PRN} echo "Done!"
echo "\nTesting Unix Spooler"
echo "\nDo you want to print a Test Print (Y/N)
[Default=y] ? \c"
read CORRECT
if [ "$CORRECT" = "" ]; then
CORRECT="Y"
fi
if [ ${CORRECT} = "Y" ] || [ ${CORRECT} = "y" ]; then
banner "${UNIX_PRN}" | lp -d ${UNIX_PRN}
echo "Printed Test Print via Unix ..."
sleep 5
tail -60 /usr/spool/lp/logs/requests | grep
${UNIX_PRN}
echo "\nWas Test Print Successful (Y/N)
[Default=y] ? \c"
read CORRECT
if [ "$CORRECT" = "" ]; then
CORRECT="Y"
fi
if [ ${CORRECT} = "N" ] || [ ${CORRECT} = "n" ];
then
exit 0
fi
fi
echo "\nDo you want to add this Printer as an AFPS SHARE
(Y/N) [Default=y] ? \c"
read CORRECT
if [ "$CORRECT" = "" ]; then
CORRECT="Y"
fi
if [ ${CORRECT} = "Y" ] || [ ${CORRECT} = "y" ]; then
if [ -d /usr/net/servers/lanman ]; then
echo "\nAdding Printer as the SHARE ${SHARE_PRN}
... "
net share ${SHARE_PRN}=${UNIX_PRN} /PRINT
net share ${SHARE_PRN} /REMARK:"${DESC}"
net print ${SHARE_PRN} /REMARK:"${DESC}"
net share | grep ${SHARE_PRN}
net access \\${SHARE_PRN}
echo "Done!"
else
echo "\nNon AFPS Server !"
fi
fi
echo "\nSUGGEST PUTTING A LABEL ON THE PRINTER SAYING:-"
echo "\n${SHARE_PRN}"
echo "${IP_ADDR}\n"
else
echo "No HPNP Configuration File Exists !"
exit 0
fi
else
echo "Correct the Entry in /etc/hosts !"
exit 0
fi
fi
fi
echo -n "\nEnter next Printer Identifying Number (eg: 002) (Enter X to eXit): "
done
# End.-----NOTES: Should non-root users be unable to print to a printer connected to a
Windows 2000 server follow the suggested workaround below:# cd /usr/net/servers/lanman/bin
# chown root cliprt
# chmod u+s cliprtNext, you have to create a simple shell script which makes use of the above binary as to print (as root) to the W2K server with the following syntax:
# cliprt -w <servername> -s <printername> <filename>|<stdin> See also
ta100068, "Configuring AFPS shared client printing to an NT 4.0 Server."
ta116651, "What is Support Level Supplement (SLS) APP619A, the Advance File and Print Server 4.0.2 Supplement?"