Check the /usr/sam/lbin/lpmgr file for this. Yhe following script would give you an idea, on what files should be exactly checked.
This is used to add a printer on HP-UX systems.
Code:
=================================================
#!/usr/bin/sh
###############################################################################
#
# Script: add_printer
#
# Purpose: add remote printer for claims systems
#
# Author : nua7
###############################################################################
basename=${0##*/}
export PATH=$PATH:/usr/sbin:/claims/amxw/SYS2/BIN
trap 'print "$basename: Unexpected rc $? at line $LINENO"; exit 1' ERR # exits script for any non-zero return-code
trap '
#
# command to clean up on any script exit, any rc value
#
# start lp scheduler if necessary
if lpstat -r | grep -q "scheduler is not running" ; then
/usr/sbin/lpsched > /dev/null
fi
' EXIT
# function to display usage message and exit
#
function usage
{
print "Usage: $(basename $0) printer_name printer_queue print_server"
print
print "Description:"
print " Add a printer definition to the AMXW MPE-emulation environment."
print
print "Parameters:"
print " printer_name local name for printer (ex. L101)"
print " printer_queue queue name on print server"
print " print_server name of network print server"
print
print "Example:"
print " $(basename $0) L101 pcl299 nvbqxyz"
exit 1
}
#
# variable definitions
#
if [[ $# -ne 3 ]]; then
usage
fi
localname=$1
remotename=$2
remotesystem=$3
# # # # # # # # # # # #
# main section
# # # # # # # # # # # #
# validate that printer does not exist
if lpstat -s | grep -q "device for $localname:" ; then
print "ERROR: printer $localname already exists - cannot add"
exit 1
fi
typeset -uL1 ANS
print "Verify if this remote queue and print server already in use"
print
if /usr/sam/lbin/lpmgr | grep "$remotename on $remotesystem" ; then
print
print "WARNING: this remote queue/print server combination already in use"
print " on this system (see above)"
print
print -n "Continue building this queue? <n> "
read ANS
if [[ "$ANS" != "Y" ]]; then
print
print "Exiting add_printer without building queue"
print
exit 0
fi
else
print " not in use ... continuing"
fi
# stop lp scheduler if running
if lpstat -r | grep -q "scheduler is running" ; then
/usr/sbin/lpshut > /dev/null
fi
echo
echo ">>> adding \"$localname\" for $remotename on $remotesystem"
# Performing task "Add Remote Printer": Adding "$localname"
if [[ $(echo $remotename | grep null | grep -v grep | wc -l) -gt 0 ]] ; then
/usr/sbin/lpadmin -p$localname -v/dev/null -g0 -mPCL5
/usr/sam/lbin/lpmgr -e -xlocalname=$localname
#/usr/sbin/accept $localname
#/usr/bin/enable $localname
else
/usr/sam/lbin/lpmgr -a -xlocalname=$localname,default=n,fence=2,rc=n,is_bsd=n,remname=$remotename,remsys=$remotesystem,remcancel=rcmodel,remstatus=rsmodel 2>/dev/null
/usr/sbin/lpadmin -p$localname -orm$remotesystem -orp$remotename -mrmodel -v/dev/null -ocmrcmodel -osmrsmodel
fi
# start lp scheduler to ensure validation in next step succeeds
if lpstat -r | grep -q "scheduler is not running" ; then
/usr/sbin/lpsched > /dev/null
fi
echo
echo '>>> validating new device - please review output'
lpstat $localname
# add device to DEVICES.PUB.SYS as necessary
if print $localname | grep -q ^[A-Z] ; then
# MPE-oriented printer - add to DEVICES file if it exists
if [[ -f /claims/amxw/SYS/PUB/DEVICES ]]; then
if ! grep -q "PRINTER $localname" /claims/amxw/SYS/PUB/DEVICES ; then
LDEV=$(get_new_ldev)
add_new_ldev "$LDEV PRINTER $localname $localname"
fi
fi
fi
# # # # # # # # # # # #
# script complete
# # # # # # # # # # # #