Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Automate adding SMB printers with required passwords Printers
We use a printer accounting system, which requires that the username and password be passed as a parameter in the smb URI. LPD wouldn't be an option in this case. I've created a script that I run when I've changed my password.

echo -n "Enter your username: "
read username
echo -n "Enter your password (what you type will not be printed to the screen): "
read -s password
echo " "
echo "If you are prompted for a password, enter your system administrator password"
#$domain and $servername must be defined
sudo lpadmin -p 1055CMBond -v smb://$username:$password@$domain/$servername/hp1055cmbond -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP DesignJet 1055CM PS3.gz"
sudo /usr/bin/enable 1055CMBond
sudo /usr/sbin/accept 1055CMBond
#make the printer the default, may require system password
sudo lpoptions -d 1055CMBond
#At one point I thought this was necessary
#uncomment if you need it
#sudo killall -HUP cupsd

This will overwrite printers with the same name, so they are essentially deleted and re-created with the new password. You'll need to define your domain and server name. As well, you'll need to know the path to the PPD file for your specific printer. My advice would be to define the printers manually the first time, and then peek into your printers.conf file for the PPD paths.
  • Currently 2.50 / 5
  You rated: 4 / 5 (8 votes cast)

Automate adding SMB printers with required passwords | 2 comments | Create New Account
Click here to return to the 'Automate adding SMB printers with required passwords' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automate adding SMB printers with required passwords
Authored by: corienti on Apr 05, '07 08:13:07PM

If you add a -E flad to the lpadmin command that re-adds your printer, you can then skip the "enable" and "accept" lines. The -E flag to lpadmin tells lpadmin to automatically enable and accept the printer queue upon adding it.

[ Reply to This | # ]
Automate adding SMB printers with required passwords
Authored by: dennymingus on Apr 06, '07 06:14:20AM


I'll try lpadmin with the -E option instead.

[ Reply to This | # ]