Hi,
We are migrating print server in our environment, on existing server we have around 20 printers configured and users have mapped printers according to their requirement.
We want to migrate the printer on the user’s machine to new servers from the existing server.
I need help to fetch the configuration settings of the existing printer, so that I can recreate same for new printer.
I created below script to get the printer name and destination from the machine and modify the name and destination to new print server and create new printer on the machine. However after script execution the new printer is appearing in the terminal (lpstat –v) but not in the printer preference of the machine.
Thanks in advance.
#!/bin/sh
print_names=('ABCPS02_ABCP1-32310_HPM553' 'ABCPS01_ABCP1-32310_HPM553' 'ABCPS02_ABCP1-2450_HPM233')
old_server1="ABCPS01"
New_server1='ABCPS01P'
old_server2="ABCPS02"
New_server2='ABCPS02P'
Default_printer=$(lpstat -d |awk '{print $4}')
for print_name in "${print_namesa@]}"; do
if i "${print_name}" = +(ABCPS01*|ABCPS02*) ]]; then
if i $print_name == "ABCPS01"* ]]; then
New_printer="${print_name/$old_server1/$New_server1}"
old_printer_adderss=$(lpstat -v $print_name |awk '{print $4}')
New_printer_adderss="${old_printer_adderss/$old_server1/$New_server1}"
# echo "creating new printer $New_printer"
lpadmin -p $New_printer -D $New_printer -v $New_printer_adderss
# echo "remove existing printer $print_name"
lpadmin -x $print_name
if i $print_name == $Default_printer ]]; then
lpoptions -d $New_printer
fi
fi
if i $print_name == "ABCPS02"* ]]; then
New_printer="${print_name/$old_server2/$New_server2}"
old_printer_adderss=$(lpstat -v $print_name |awk '{print $4}')
New_printer_adderss="${old_printer_adderss/$old_server2/$New_server2}"
# echo "creating new printer $New_printer"
lpadmin -p $New_printer -D $New_printer -v $New_printer_adderss
# echo "remove existing printer $print_name"
lpadmin -x $print_name
if i $print_name == $Default_printer ]]; then
lpoptions -d $New_printer
fi
fi
fi
done