Return results of AppleScript (or Shell command) called from Illustrator ExtendScript
I'm running an Illustrator ExtendScript on MacOS and am trying to get the user initials without having to ask for them from the user. I thought I could try using the long user name from the system as one option...
I can use this Shell command to return the initials:
dscl . -read /Users/$(whoami) RealName | tail -n 1 | awk '{ for(i=1;i<=NF;i++) printf "%s", tolower(substr($i,1,1)) }'
Or this AppleScript:
tell application "System Events"
set fullName to words of (long user name of (system info))
set initials to ""
repeat with namePart in fullName
set initials to initials & character 1 of namePart
end repeat
return initials
end tell
How do I run either of these from the Illustrator .jsx and get the results returned to it?
I tried saving the Applescript code above in a .app on the Desktop and called it with the following code, but can't figure out how to get the results returned back into the original .jsx:
var applescript = new File("~/Desktop/Test.app");
var results = applescript.execute();
alert(results);
