Spacer http://macenterprise.org MacResource.org - Mac OS X enterprise deployment project Spacer
Site Map Contact Us Site Map About Us Top Background
 
Search
 
 
Samba Assistant E-mail
Written by Chad Barraford   
Friday, 25 May 2007
Adding smb (samba) printers can be painful and hard for many Mac users. This script makes it eaiser for printing to windows print servers. You MUST customize the script to your network. Change the server address and location in the "do shell script" command.


--GET USERNAME AND PASSWORD

to getusername()

display dialog "Enter your username:" default answer ""

set username to text returned of result

return {username}

end getusername

to getadminpwd()

display dialog "Enter your password:" default answer "" with hidden answer

set adminpwd to text returned of result

return {adminpwd}

end getadminpwd

set username to getusername()

set adminpwd to getadminpwd()




-- SET MISC VARIABLES

tell application "Finder"

set mydisk to get name of startup disk

end tell

set ppdDefaultLocation to mydisk & ":Library:Printers:PPDs:Contents:Resources:en.lproj:"

set printersInstalled to "Printers Installed:"



--FUNCTION THAT RUNS SHELL SCRIPT TO ADD THE PRINTERS

to addprinter(ppd, username, adminpwd, printerName, printersInstalled)

set ppdPath to POSIX path of ppd

try

do shell script "lpadmin -p" & printerName & " -vsmb://" & username & ":" & adminpwd & "@SERVER/ADDRESS/" & printerName & " -E -P" & quoted form of ppdPath & " -LLOCATION -D'" & printerName & "'"

set printersInstalled to return & printerName & " Successful"

on error

set printersInstalled to return & printerName & " Failed"

end try

return printersInstalled

end addprinter



repeat

display dialog "Enter printer queue name. You must be EXACT!" default answer ""

set printerName to text returned of result

set ppd to choose file default location alias ppdDefaultLocation

set printersInstalled to printersInstalled & addprinter(ppd, username, adminpwd, printerName, printersInstalled)

display dialog "Would you like to add another printer?" buttons {"Yes", "No"} default button "No"

if button returned of result is "No" then

exit repeat

end if

end repeat


display dialog printersInstalled buttons {"OK"} default button "OK"


Add as favourites (227) | Quote this article on your site | E-mail

Comments (2)
RSS comments
1. 29-02-2008 19:31
Chris Gerke
2. 29-02-2008 19:33
I use this in a loginscript that runs once (the first time the user logs in). 
 
 
#!/bin/bash 
# Query the current users department 
# Using niutil 
# dept=$(niutil -read . /users/$USER | grep department | sed -n s/department://p | sed 's/^[ \t]*//') 
# Using dscl 
dept=$(dscl . read /users/$USER | grep Department | sed -n s/Department://p | sed 's/^[ \t]*//') 
printserver="sydneyprintserver3k08.com" 
canon_3220_ppd="/Library/Printers/PPDs/Contents/Resources/en.lproj/CNRC322E1.PPD" 
canon_3570_ppd="/Library/Printers/PPDs/Contents/Resources/en.lproj/CNR357E1.PPD" 
 
case "$dept" in  
'Finance')  
lpadmin -p 3220canon-Finance -L "Level-1" -E -v lpd://$printserver/3220canon01 -P "$canon_3220_ppd" 
;; 
'Information Technology')  
lpadmin -p 3570canon-IT -L "Level-1" -E -v lpd://$printserver/au3570canon01 -P "$canon_3570_ppd" 
;; 
'Operations')  
lpadmin -p 3220canon-Operations -L "Level-3" -E -v lpd://$printserver/3220canon02 -P "$canon_3220_ppd" 
;; 
esac 
 
exit 0
Chris Gerke

Only registered users can write comments.
Please login or register.

Powered by AkoComment Tweaked Special Edition v.1.4.4

Last Updated ( Thursday, 03 January 2008 )