I already register multiple printer in my server and want to copy printer configuration from one server to another server which both based on Solaris 10.
I realize that there are many ways to do this but I choose using this script because I think it’s simple
If you want to use this, maybe you need some modification using these scripts because of different rule of printer naming configuration that you want to set but hopefully it will help you a little
There 2 scripts that I used : exprint.sh and imprint.sh
Copy scripts_print folder from source server to destination server
Please put imprint.sh on scripts_print folder on destination server
Don’t forget to set these two file permission as executable file (chmod 755)
On Source Server
Execute exprint.sh as root
Script expprint.sh :
# Use Bash (Bourne again shell) for running this script
mkdir scripts_print
ls /etc/lp/printers > ./scripts_print/printer
for i in `ls /etc/lp/printers`
do
lpstat -p $i -l | grep Options | cut -f2 -d= | cut -f1 -d, | cut -f1 -d ":" >> ./scripts_print/ip_address
lpstat -p $i -l | grep Options | cut -f2 -d= | cut -f1 -d, | cut -f2 -d ":" >> ./scripts_print/port
echo " Printer Description" >> ./scripts_print/desc
done
nawk '{ gsub(/_/,""); print }' printer | nawk '{$0=tolower($0);print}' > /tmp/test
awk '{ for ( i = 1 ; i < 2 ; i++ ) {a=i;b="mch_"; print b $a } }' /tmp/test > ./scripts_print/dev
On Destination Server
Execute imprint.sh as root
Script imprint.sh:
# Use Bash (Bourne again shell) for running this script
fnImportPrintersFunction()
{
mv printer.log printer.log.orig
i=0
while read line
do
f1[$i]="$line"
let i++
done <$1
i=0
while read line
do
f2[$i]="$line"
let i++
done <$2
i=0
while read line
do
f3[$i]="$line"
let i++
done <$3
i=0
while read line
do
f4[$i]="$line"
let i++
done <$4
i=0
while read line
do
f5[$i]="$line"
let i++
done <$5
i=0
while [[ "${f1[$i]}" ]]
do
touch /var/tmp/${f1[$i]}
chmod 600 /var/tmp/${f1[$i]}
echo "${f2[$i]} ${f3[$i]} creation" >> printer.log
/usr/sbin/lpadmin -p ${f2[$i]} -v /var/tmp/${f1[$i]} -T hplaser -I any -A mail -i /usr/lib/lp/model/netstandard -o dest=${f3[$i]}:${f4[$i]} -o protocol=tcp -o banner=never -D "${f5[$i]}" >> printer.log 2>&1
RC=$?
if [ $? -eq 0 ]
then
echo "${f2[$i]} ${f3[$i]} creation successfully" >> printer.log
else
echo "${f2[$i]} ${f3[$i]} creation failed" >> printer.log
fi
/usr/bin/enable ${f2[$i]}
/usr/sbin/accept ${f2[$i]}
sleep 1
let i++
done
}
fnImportPrintersFunction dev printer ip_address port desc
No comments:
Post a Comment