I’m trying to get a mac to report back the version of curl. I’m able to do it with linux and pc but not sure how to get it to work with mac.
if name of operating system as lowercase starts with "win" then
if (exists file "C:\windows\system32\curl.exe") then (version of file "C:\windows\system32\curl.exe" as string)
else "File does not exist"
else if name of operating system as lowercase starts with "mac" then
if (exists file "/usr/bin/curl") then (version 1 of file "/usr/bin/curl" as string)
else "File does not exist"
else if name of operating system as lowercase starts with "linux" then
if (exist installed "curl" of rpm) then (version of package "curl" of rpm as string)
else "File does not exist"
else "OS Not Found"
Returns the nth version information from the “vers” resource of the given file. Typically n=1, but other information may be stored in “vers” resources greater than 1.
looks like I got it. I had to go about it in a very wonky way. what I discovered is most things mac doesn’t have version information in the properties including curl. I did find that in the curl-config file that it had some information about libcurl which should get me enough info. so I targeted that and returns some information
if name of operating system as lowercase starts with “win” then
if (exists file “C:\windows\system32\curl.exe”) then (version of file “C:\windows\system32\curl.exe” as string)
else "File does not exist"
else if name of operating system as lowercase starts with “mac” then
if (exists file “/usr/bin/curl-config”) then
(following text of first “libcurl” of (line containing “echo libcurl” of file “/usr/bin/curl-config”) as trimmed string)
else "File does not exist"
else if name of operating system as lowercase starts with “linux” then
if (exist installed “curl” of rpm) then (version of package “curl” of rpm as string)
else "File does not exist"
else “OS Not Found”
As context, macOS is a 'nix-style OS, but the 'nix utilities aren’t provided by a 'nix-style package manager (e.g. rpm). Ergo, we’re left to parsing a text file (like /usr/bin/curl-config) or juggling stdout.
I assume we’re looking at curl because of CVE-2023-38545? If so, it’s worth reading the curl maintainer’s own words: