I have LaunchAgent plist file that contains the following Program Arguments


The initial path to the embedded java distribution (int this case version jre1.8.0_121.jre) changes when the people from Ubiquiti update their application, but the installed that they provide does not include the LaunchAgent modification, so I have to do it by hand every time.

I tried to put something like


… but as I have read here there is no substitution inside the plist file.

Any ideas on how to achieve this? This way the plist file can stay the same regardless the updated version of the embedded distribution.

Thank you you all

1 Answer 1


I haven't tested it, but you should be able to add <EnableGlobbing><true/> to the plist file, and use the wildcard. From the launchd.plist man page:

EnableGlobbing <boolean>

This flag causes launchd to use the glob(3) mechanism to update the program arguments before invocation.

Since this doesn't seem to be working, another possibility that occurred to me is to run a shell, and let it to the wildcard expansion. You could create a short script, and have launchd run that, or just use bash -c:

        <string>exec /Applications/UniFi.app/Contents/PlugIns/jre*.jre/Contents/Home/jre/bin/java -Djava.awt.headless=true -Xmx1024M -jar /Applications/UniFi.app/Contents/Resources/lib/ace.jar start</string>

Note that since it's being passed to a shell via -c, the entire command (including arguments) must be passed as a single long argument separated by spaces rather than as separate arguments. Also, I added exec so the shell will replace itself with the java executable rather than hanging out as a (useless) parent process.

  • You are completely right. I thought the EnableGlobbing tag was only meant to use substitution in variables or ~ for the home folder of the user. Great and simple… and it works like a charm. Thank you very much Gordon
    – Bottacco
    May 13, 2017 at 11:26
  • Sorry, but after a thorough test it doesn't work. I have tried with multiple examples to see if it had to do with a specific case but it doesn't work. I have look to the man page but I get nothing.
    – Bottacco
    May 17, 2017 at 18:25
  • @Bottacco I'm not sure why it wouldn't work (and I don't have time to test right now), but I added another possible approach. May 17, 2017 at 20:21
  • Hi Gordon, I have tried your second approach and it is the correcto one. This one does work all the time even if I reinstall the complete package from Ubiquiti and it doesn't matter the version of the embedded Java runtime that they include. Thank you very much for your suggestions and I don't know why the first approach is not working because the man page states that globbing should do it. Anyway, thanks a lot
    – Bottacco
    May 18, 2017 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.