Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to obtain an application's Bundle ID (or plist path) from only the PID?
    text
    copied!<p>Similar to <a href="https://stackoverflow.com/questions/3309681/how-to-find-bundle-identifier-from-known-pid">"How to find Bundle Identifier from known PID?"</a> and to <a href="https://stackoverflow.com/questions/4328501/how-to-read-plist-information-bundle-id-from-a-shell-script">"How to read plist information (bundle id) from a shell script</a>, but different.. as those are both related to Xcode build variable expansion, etc.</p> <p><strong>My question is how, in a BASH shell, where they only known value is the process' PID, how can one obtain that process' <em>PATH, or unique "Bundle ID".</em></strong></p> <p>I am sure there is a hideous regex to parse ps, but I'm hoping for something cleaner and more portable. The comments in those prior mentioned posts included</p> <pre><code>BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${BUILD_ROOT}/${INFOPLIST_PATH}") </code></pre> <p>However, I do not think <code>plistbuddy</code> is installed on every Mac, and more importantly, my question is within a theoretical script, NOT within an Xcode build phase..</p> <p>I've tried <code>plutil</code>, <code>plistkit</code>, and <code>plistdump</code>, and none of them seem to do the trick..</p> <p>The reason I am trying to achieve this is to be able to execute <code>defaults read</code> / <code>write</code> functions without hardcoding the BundleID of the parent process. I know how to pass this info as an argument to a script.. but I want to be able to doubt check.. within the script.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload