To verify applications in Terminal is not an issue, but how can I get same results in Applescript?
set appSig to (do shell script "codesign -dv /Applications/Books.app")
To verify applications in Terminal is not an issue, but how can I get same results in Applescript?
set appSig to (do shell script "codesign -dv /Applications/Books.app")
Since Big Sur, the Mac has 2 partitions of the boot drive that are merged at runtime.
This is for security reasons. The âSystemâ part contains all the OS and OS included applications.
There the âBook.appâ is really in location â/System/Applications/â
User installed apps are in â/Applications/â.
so the AppleScript is
set appSig to do shell script "codesign -dv /System/Applications/Books.app 2>&1"
had to set stderr to stdout to get the results
Maybe, your application doesnât open due to other reason as well. Try to remove gatekeeper quarantine as additional step. This step is useful for applications from unknown (to Apple) developers. Example I use for my Mac:
set theApp to ((path to applications folder) as text) & "Avidemux_2.7.8.app"
set appPosixPath to POSIX path of theApp
set quotedPath to quoted form of appPosixPath
do shell script "xattr -rd com.apple.quarantine " & quotedPath with administrator privileges
Thanks to both for your awesome suggestions,
My problem is, i get an empty string in âScript Editorâ like this:
Tell current application
do shell script "codesign -dv /Applications/Books.app"
--> ""
Meanwhile i get a normal and complete output in âTerminalâ
It doesnât matter what app i check with âScript Editorâ, results are always empty and results in Terminal are always complete
WOW.
It seems you didnât read any of my previous post which explains this.
For Big Sur or newerâŚ
do shell script "codesign -dv /System/Applications/Books.app 2>&1"
or on older OSes
do shell script "codesign -dv /Applications/Books.app 2>&1"
@Joy
You could run this code⌠to get the path on your system.
use framework "AppKit"
use framework "Foundation"
use scripting additions
tell application "Books" to set bundleId to its id
set workspace to current application's NSWorkspace's sharedWorkspace()
((workspace's URLForApplicationWithBundleIdentifier:bundleId)'s valueForKey:"path") as string
or you could just use regular AppleScript
POSIX path of (path to application "Books")
so the full script line would be (for all OS versions)
do shell script "codesign -dv " & (POSIX path of (path to application "Books")) & " 2>&1"
Yes, quite strange indeed. I confirm that all your scripts on this topic gives me the desired result. Itâs weird to think that they only works for the two of us.
Regarding the Posix path of app: it can be retrieved without application launching as well. Also, quoted form is preferable:
on codeSignInfoFor:appName
set bundleID to id of application appName
tell application "Finder" to set appHFSpath to application file id bundleID as Unicode text
set appQuotedPosixPath to quoted form of POSIX path of appHFSpath
do shell script "codesign -dv " & appQuotedPosixPath & " 2>&1"
end codeSignInfoFor:
my codeSignInfoFor:"Safari"
Thanks KniazidisR,
Here is a slightly different version that uses âSystem Eventsâ instead of âFinderâ
EDIT having problems , found bug
tell application "System Events" to set myApp to application "Books"
set appQuotedPosixPath to quoted form of POSIX path of (path to myApp)
do shell script "codesign -dv " & appQuotedPosixPath & " 2>&1"
Only problem with âSystem Evemtsâ is you have to hard code the app name. You canât use a variable or it will error out.
EDIT - crap, it still is launching the app. DAM, I tried
Are you sure
set appNames to (choose from list {"App Store", "Books", "Calendar", "Mail"}) as string
set theName to a reference to application appNames
tell application "System Events" to set myApp to theName
set appQuotedPosixPath to quoted form of POSIX path of (path to myApp)
end
return appQuotedPosixPath
But the App still launches
The only tell block I have in this example is to tell Books to quit.
set appName to "Books"
set appPath to a reference to path to application appName
try
tell application "Books" to quit
end try
return POSIX path of (appPath as text)
And this lead me toâŚ
set appName to (choose from list {"Books", "Calculator", "Notes"}) as string
set appPath to a reference to path to application appName
try
tell application appName to quit
end try
return POSIX path of (appPath as text)
Ps. path to belongs to standard additions so it doesnât need a tell block.
Ops, i skimmed your post and didnât notice you redirected the output to stdout.
Now itâs working
Thanks again to everyone