Operating System - HP-UX
1753789 Members
7270 Online
108799 Solutions
New Discussion

Re: Scripting printer additions on HP-UX B.11.31

 
Greg W. Webster
Occasional Advisor

Scripting printer additions on HP-UX B.11.31

Hello all!

 

I have a lot of printer queues to bring from one old HP-UX server to a new one and don't really want to use 'hppi' for each one...I found an old script for doing these additions in lp (http://www.knowledgeroot.com/hp-ux/printer/create-printer-on-hp-ux-using-script/), and it does add a queue in /etc/lp/members, but the printer queue is not then showing in hppi. It shows up fine (accepting connections) with "lpstat -a".

 

Is there a better way to handle this so that I can script additions but they are available in hppi?

 

Thanks!

2 REPLIES 2
V. Nyga
Honored Contributor

Re: Scripting printer additions on HP-UX B.11.31

Hi,

have you tried SAM utilities?
SAM - Printers and Plotters - LP Spooler - Save/Restore Spooler Config (this works at least in 11.11)

HTH
V.
*** Say 'Thanks' with Kudos ***
rmueller58
Valued Contributor

Re: Scripting printer additions on HP-UX B.11.31

I have about 250 queues, we've migrated OS's a couple of times. I scripted on 11.11 using the addqueue command.

 

I would run things through a do while or "for do script.

 

export SDE=`date +%m/%m/%Y`
echo $SDE
export STI=`date +%T`
echo $STI
echo "Enter IP Address of Printer:\n"
read IP     
sed s/IPADDRESS/$IP/g TEMPLATE >TEMPLATE2
echo $QN
read
sed s/QUENAME/$QN/g TEMPLATE2 >TEMPLATE3
chmod 775 TEMPLATE3
./TEMPLATE3
chmod 600 TEMPLATE3

# more TEMPLATE
addqueue -i PTYPE -h IPADDRESS -q QUENAME -b off
lp -dQUENAME /tmp/test

 

If your printers are HP brand printers with SNMP enabled generally this works fairly well.

 

You would have to modify the script to fit your need, I use mine in a one by one thing now.

 

you would need a delimited file, Containing "PRINTERTYPE" "IPADDRESS" and "QUENAME"

 

the snag is generally the printer type.

We have some of the newer MFP's that are Toshiba or Ricoh and have to use hppi -s and because they do not comply with the HP/Canon engine, they are not recognized on HP

 

on HP there is a port for CUPS.this allows for a broader range of printers..

 

 

For we worked on a migrations to CUPS from HP and came up with a semi-workable solution.

this script would build a cups file based on your current HP queues:

 

#!/bin/sh
echo $qname $ipaddr
for qname in `ls /var/spool/lp/interface/*`                                     
do
export ipaddr=`grep PERIPH= "$qname" |grep -v MODEL | awk -F'=' '{print $2}'`

echo $qname $ipaddr

outfile=$1
if [ -z "$outfile" ]
then
echo "USAGE: hp2cups <output file>"
exit 1
else
> $outfile
fi

/usr/sam/lbin/lpmgr | while read printnfo
do
isremote=`echo $printnfo \
| cut -d":" -f3 \
| cut -d"," -f1`
if [ "$isremote" = "yes" ]
then
name=`echo $printnfo | cut -d":" -f1`
remote=`echo $printnfo \
| cut -d":" -f5 \
| awk '{print $3}'`
cat >> $outfile << EOF
<Printer $qname>
Info Created by $USER
DeviceURI socket://"$ipaddr":9100
Location
State Idle
Accepting Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
</Printer>
EOF
fi
done
#########################################
done