DUTI - question on usage and ARD or scripting

mrector
New Contributor

I've compiled and installed duti and can run local commands just fine. But I cannot seem to get shell scripts set via JAMF policies to execute successfully nor sending Duti commands via ARD.

I know I'm missing something. What I have sent appears to run correctly and I get no obvious errors from commands that I have run from both a script in a policy or by using ARD - but the file handler changes do not actually take hold.

Does anyone have an example of a shell script using Duti or a successful command using ARD that they wouldn't mind sharing?

Thanks.

5 REPLIES 5

blindcola
New Contributor III

Script for casper. Been awhile since i used this, very basic. appid is something like (com.apple.preview) and type/UIT would be (public.jpeg) to set preview as the default view for all .jpeg files. I believe it has to be run with a logged in user but like i said i have not messed around with it for a while.
Edited: to include the notes i'd left myself incase i needed to deploy this again. Hope this helps.

#!/bin/bash

appid=$4
type=$5

sudo -u $3 /usr/local/bin/duti -s $appid $type all

exit 0

Download the source for duti from the above webpage (page links to git). Compile and install the applications while running a composer session. It will install two files onto the system. /usr/local/bin/duti & /usr/local/share/man/man1/duti.1 Install this package on systems you wish to control default application file associations. These will be controlled on a user level basis.

File runs with command "duti -s -BundleID -UIT -Role" ie duti -s com.apple.Preview public.jpeg All. BundleID is found in the /Applications/App Name/Contents/info.plist and the CFBundleIdentifier. UIT UniformTypeIdentifier (Media Type). The UIT's an applications can open are also listed in the info.plist. This space can also be used to set a URL Scheme like ftp to assign all urlschemes to open in say com.apple.safari The final variable is the Role. Role in the provided script is set to ALL. This can also be run as view,editor and shell. If your are assigning a URL Scheme the role is not assigned.

When running via casper select the "set file associations.sh" and set to deploy on login. Parameter 4 sets the BundleID Parameter 5 sets the UIT. In this script sudo -u is run with Parameter 3 so the association is set to the currently loggin in user. When scripting the full path /usr/local/bin/duti is required.

mrector
New Contributor

Thanks David, unfortunately I'm not able to get that scenario to work either. For example in ARD I send out the command as root: /usr/local/bin/duti -s com.adobe.acrobat.pro pdf all This sends out and notifies as being successful but does not work. If I enter the same command at the workstation : duti -s com.adobe.acrobat.pro pdf all - it works perfectly.

With Casper setting up the script as you show: and using the script filename "pdf_handler.sh"
#!/bin/bash
appid=$4
type=$5
sudo -u $3 /usr/local/bin/duti -s $appid $type all
exit 0

and then setting up the script details in casper admin with:
Parameter 4: com.adobe.acrobat.pro
Parameter 5: pdf
set for login

Result in Logs:
Executing Policy set pdf handler...
Mounting Lhotse Distribution Point to /Volumes/CasperShare...
Running script pdf_handler.sh...
Script exit code: 0
Script result: usage: /usr/local/bin/duti [ -hvV ] [ -d uti ] [ -l uti ] [ settings_path ]
usage: /usr/local/bin/duti -s bundle_id { uti | url_scheme } [ role ]
usage: /usr/local/bin/duti -x extension

Then if I change the pdf_handler.sh to:
#!/bin/bash
sudo -s /usr/local/bin/duti -s com.adobe.acrobat.pro pdf all
exit 0

The Result in the logs is the same.

Thanks.

blindcola
New Contributor III

try it with the UIT set as com.adobe.pdf

sudo -s /usr/local/bin/duti -s com.adobe.acrobat.pro com.adobe.pdf all

You can find the a list of UIT's an application can open by doing a show package contests on the app and looking at the info.plist file.

mrector
New Contributor

Unfortunately no dice. It's so odd that it works just fine if you sit at the computer and type in:
duti -s com.adobe.acrobat.pro pdf all and sending from ARD (/usr/local/bin/duti -s com.adobe.acrobat.pro pdf all) it doesn't work.

Thanks for your help. I may just have my student staff do some nice repetitive keyboarding!

blindcola
New Contributor III

i'll poke around with the software over the holiday break, i'd like better documentation for it anyway. but i'd say look at the CFBundleIdentifier your using and make sure it's the correct one for the version of acrobat your using. I've only bothered deploying this for one instance and i believe i needed to run it on the login hook to get the thing to work right.