Navigation

6/19/2014

Applescript: Keychain add/delete


Security command syntax, from Apple Developer pages.



http://macscripter.net/viewtopic.php?id=36818

security add-internet-password  -a cua\\\\userName  -l '2nd-floor'  -s ntsrva.cua.edu   -p LAW228_PRINTER_QUEUE   -r 'smb '  -w  Password  -D 'network password'  -A



add-internet-password [-h] [-a account] [-s server] [-w password] [options...] [keychain]
            Add an internet password item.

            -a account      Specify account name (required)
            -c creator      Specify item creator (optional four-character code)
            -C type         Specify item type (optional four-character code)
            -d domain       Specify security domain string (optional)
            -D kind         Specify kind (default is "application password")
            -j comment      Specify comment string (optional)
            -l label        Specify label (if omitted, service name is used as default label)
            -p path         Specify path string (optional)
            -P port         Specify port number (optional)
            -r protocol     Specify protocol (optional four-character SecProtocolType, e.g. "http", "ftp ")
            -s server       Specify server name (required)
            -t authenticationType
                            Specify authentication type (as a four-character SecAuthenticationType, default
                            is "dflt")
            -w password     Specify password to be added
            -A              Allow any application to access this item without warning (insecure, not recom-mended!) recommended!)
                            mended!)
            -T appPath      Specify an application which may access this item (multiple -T options are
                            allowed)
            -U              Update item if it already exists (if omitted, the item cannot already exist)

            By default, the application which creates an item is trusted to access its data without warning.
            You can remove this default access by explicitly specifying an empty app pathname: -T "". If no
            keychain is specified, the password is added to the default keychain.
 
 
 delete-internet-password [-h] [-a account] [-s server] [options...] [keychain...]
            Delete an internet password item.

            -a account      Match account string
            -c creator      Match creator (four-character code)
            -C type         Match type (four-character code)
            -d securityDomain
                            Match securityDomain string
            -D kind         Match kind string
            -j comment      Match comment string
            -l label        Match label string
            -p path         Match path string
            -P port         Match port number
            -r protocol     Match protocol (four-character code)
            -s server       Match server string
            -t authenticationType
                            Match authenticationType (four-character code) 

6/16/2014

Applescript: administrator privileges




How do I get administrator privileges for a command?

Use the administrator privileges, user name and password parameters like this:
 
do shell script "command" user name "me" password "mypassword" with administrator privileges

user name and password are optional; if you omit the user name, do shell script assumes it to be the current user; if you omit the password, it will ask for a password when it runs. Once a script is correctly authenticated, it will not ask for authentication again for five minutes. As of Mac OS X 10.4, this grace period does not extend to any other scripts or to the rest of the system;

6/10/2014

Applescript: installing windows print queue


Looking to install windows print queue on Apple OS via Apple script

This is path, with the username/password embedded
smb://domain\\\\userName:Password@server.address.edu/queueName

do shell script "/usr/sbin/lpadmin -p  3rd-floor -v smb://CUA\\\\" & userName & ":" & ThePassword & "@server.address.edu/queueName -P   " & quoted form of (POSIX path of driver3) as text & "  -D \"3rd-Floor-Library\""

do shell script "sudo /usr/sbin/accept 3rd-floor" with administrator privileges
   This sets correct access or right for the printer.


I embedded username/password because I found issues trying to use Applescript to create entries in Keychain.


lpadmin switches


 -L "location"
            Provides a textual location of the destination.

 -P ppd-file
            Specifies  a  PostScript  Printer  Description  file to use 
            with the printer. If specified, this
            option overrides the -i option (interface script). 
 
 -v "device-uri"
            Sets the device-uri attribute of the printer queue. 
            Use the -v option with the lpinfo(8) command
            to get a list of supported device URIs and schemes.

 -D "info"
            Provides a textual description of the destination. 

6/06/2014

jQuery to detect iOS

Want to display code only for iOS devices:


function isAppleDevice(){
    return (
        (navigator.userAgent.toLowerCase().indexOf("ipad") > -1) ||
        (navigator.userAgent.toLowerCase().indexOf("iphone") > -1) ||
        (navigator.userAgent.toLowerCase().indexOf("ipod") > -1)
    );
}


From jquerybyexample.com