Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

AppleScript's "try" command gives up too easily.

I want to do some conditional branching using "try." For the record, there is no user on my computer named "Batman." I want the script to continue even if it doesn't find a user this time.


Here's my code, in Snow Leopard 10.6.8:


try

do shell script "dscl . -read /Users/Batman"

on error 56 -- which reads "error "<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)" number 56"

--keep going; "Batman" is only one of a number of user names I am testing!

end try

The script fails and exits with a message that reads:


AppleScript Error


<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)


I thought the whole point of "try" was that it would allow your script to continue running even if it ran into an error...?

Apple Remote Desktop-OTHER, Mac OS X (10.6.8)

Posted on Aug 22, 2013 3:50 PM

Reply
3 replies

AppleScript's "try" command gives up too easily.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.